从first view controller
到移动时,second view controller
我将 indexpaths 保存在数组中,并在加载表时在first view controller
return 中保存,如果当前 indexpath 在保存的 indexpaths 数组中,我必须创建一个自定义附件按钮。
UITableview
但是,当与所需的单元格一起滚动时,另一个单元格也会获得自定义按钮。当我NSindexPaths
在滚动时打印时,我得到的是随机值而不是正常值。
对于上面我使用以下代码:
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
// NSLog(@"newdata value is =%d",newData);
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
UITableViewCell *cell = [self.positionsTable dequeueReusableCellWithIdentifier:@"playersInPosition"];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"playersInPosition"]autorelease];
}
UILabel *lblName = (UILabel *)[cell viewWithTag:100];
[lblName setText:[inputData objectAtIndex:[indexPath row]]];
UILabel *pname = (UILabel *)[cell viewWithTag:102];
[pname setText:[appDelegate.playersNFL objectAtIndex:[indexPath row]]];
for (NSIndexPath *object in appDelegate.indexPathList) {
if ([object isEqual:indexPath]) {
NSLog(@"saved index path values are =%@",appDelegate.savedIndexPath);
UIButton *button = [self ChangeAccessoryButtonStyle:appDelegate.indexPathList[0]];
cell.accessoryView = button;
}
}
return cell;
}