开发者社区> 问答> 正文

为什么iOS tableview的indexPath.row 显示时从1开始,下拉之后会显示0

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.array.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"indexpath.row:%lu",indexPath.row);

    static NSString *identity = @"UITableViewCell";

    [self.tableView registerClass:[ApplyTableViewCell class] forCellReuseIdentifier:identity];

    ApplyTableViewCell *applyCell = [self.tableView dequeueReusableCellWithIdentifier:identity forIndexPath:indexPath];

    if (applyCell == nil) {
        applyCell = [[ApplyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identity];

    }

    _cell = applyCell;

    _cell.showViewDelegate = self;

    applyCell.replyArr = self.replyArr;
    applyCell.model = self.array[indexPath.row];

    return applyCell;
}

展开
收起
爵霸 2016-03-06 13:52:14 2265 0
1 条回答
写回答
取消 提交回答
  • 这个是你每个数据加入table的时候告诉你当前索引数据 然后你填充对应数据

    2019-07-17 18:54:30
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载