有时候需要根据tag来获取cell,需要创建NSIndexpath,我们可能会这么用:
NSIndexPath *indexPath = [[NSIndexPath alloc] initWithIndex:tag];
没有报错,但很遗憾的是通过这样的indexPath,你是怎么都获取不到cell的!正确的创建方法是:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
if ([self.dataArray indexOfObject:model] != NSNotFound) {//数组中某一元素在数组中的位置 NSInteger inde =[self.dataArray indexOfObject:model] ; NSLog(@"-2---%ld----",inde); model.status = @"1"; [self.dataArray replaceObjectAtIndex:inde withObject:model];//替换数组中某一元素的值 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:inde inSection:0];//创建NSIndexpath [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];//刷新表格的某一行 }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。