一共有两个问题
1.
本人在CELL上面增加了5个按钮,结果是当本人点击第一个cell上面的按钮后会成为选中状态,当滑动table向下看数据的时第15个同样位置的也会选择状态,第二个cell按钮选择后第16个也会试选中状态。以此类推。有人能给讲解一下为什么吗?
2.关于存活期
本人通过navigation传递下个view,直到最后一个tableview,当点击最后一个tableview的时候回直接 推送第一个 navigation 是不是在返回之前把变量nil掉?或释放掉?假如本人从最后一个页面推送到第一个页面实际之前全部推送的页面还存在吗?假如存在怎么样关闭之前的viewtable或viewcon 也就是之前全部的视图,原因是要做一个问卷的应用所以答到最后一套题的时候需要推送到
最开始的页面,继续重复其他人答题。所以就没办法把back按钮显示。
tttt.h
1.
本人在CELL上面增加了5个按钮,结果是当本人点击第一个cell上面的按钮后会成为选中状态,当滑动table向下看数据的时第15个同样位置的也会选择状态,第二个cell按钮选择后第16个也会试选中状态。以此类推。有人能给讲解一下为什么吗?
2.关于存活期
本人通过navigation传递下个view,直到最后一个tableview,当点击最后一个tableview的时候回直接 推送第一个 navigation 是不是在返回之前把变量nil掉?或释放掉?假如本人从最后一个页面推送到第一个页面实际之前全部推送的页面还存在吗?假如存在怎么样关闭之前的viewtable或viewcon 也就是之前全部的视图,原因是要做一个问卷的应用所以答到最后一套题的时候需要推送到
最开始的页面,继续重复其他人答题。所以就没办法把back按钮显示。
tttt.h
@interface tttttt : UITableViewController
{
NSArray *S11Array;
}
ttttt.m
@interface tttttt ()
@end
@implementation tttttt
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
S11Array = [NSArray arrayWithObjects:@"丰田",@"大众",@"本田",@"日产",@"马自达",@"现代",@"通用",@"福特",@"奥迪",@"宝马",@"奔驰",@"雷克萨斯",@"奇瑞",@"吉利",@"比亚迪",@"长安",@"长城",nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [S11Array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"S7Cell";
UITableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSInteger Row = [indexPath row];
Cell.textLabel.text = [S11Array objectAtIndex:Row];
Cell.textLabel.numberOfLines =0;
UIButton *btn5 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn5 setTag:100+Row*5];
// UIButton *btn1 = [[UIButton alloc]initWithFrame:CGRectMake(10.0f, 0.0f, 450.0f, 44.0f)];
btn5.frame = CGRectMake(120.0f, 0.0f, 30.0f, 40.0f);
[btn5 setTitle:@"5" forState:UIControlStateNormal];
[btn5 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
UIButton *btn4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn4 setTag:100+Row*5+1];
btn4.frame = CGRectMake(160.0f, 0.0f, 30.0f, 40.0f);
[btn4 setTitle:@"4" forState:UIControlStateNormal];
[btn4 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
//
UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn3 setTag:100+Row*5+2];
btn3.frame = CGRectMake(200.0f, 0.0f, 30.0f, 40.0f);
[btn3 setTitle:@"3" forState:UIControlStateNormal];
[btn3 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn2 setTag:100+Row*5+3];
btn2.frame = CGRectMake(240.0f, 0.0f, 30.0f, 40.0f);
[btn2 setTitle:@"2" forState:UIControlStateNormal];
[btn2 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn1 setTag:100+Row*5+4];
btn1.frame = CGRectMake(270.0f, 0.0f, 30.0f, 40.0f);
[btn1 setTitle:@"1" forState:UIControlStateNormal];
[btn1 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
[Cell addSubview:btn1];
[Cell addSubview:btn2];
[Cell addSubview:btn3];
[Cell addSubview:btn4];
[Cell addSubview:btn5];
return Cell;
}
-(void )asender:(id)sender;
{
UITableViewCell * cell = (UITableViewCell *)[[sender superview] superview];
NSIndexPath * path = [self.tableView indexPathForCell:cell];
NSString *BnetBillMode = [ S11Array objectAtIndex:path.row];
for (int i=100+path.row*5;i<100+path.row*5+5; i++) {
UIButton *btn = (UIButton *)[self.view viewWithTag:i];
if (btn.tag==[(UIButton *)sender tag]) {
btn.selected=YES;
}else{
btn.selected=NO; }
NSLog(@"%@",btn);
}
}
@end
效果图如下
正常情况,点击第一行的第一个按钮,不滑动table的时候一切正常

当下拉想看后面的数据的时候滑动table。15行第一个按钮也同时被选中。

解决方案
20
你的变更数组存于哪里?
30
假如你用了ARC就不用本人处理内存问题