zoukankan      html  css  js  c++  java
  • IOS 创建NSIndexpath

    有时候需要根据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];//刷新表格的某一行
                    }
    
  • 相关阅读:
    docker-排除故障
    python的标识符
    python的数据类型
    python的数与字符串
    场景法
    正交试验法
    错误推测法
    决策表法
    因果图法
    python基础--用python执行系统命令
  • 原文地址:https://www.cnblogs.com/OIMM/p/11016507.html
Copyright © 2011-2022 走看看