美文网首页
ios获取指定位置的cell

ios获取指定位置的cell

作者: 加油樊先生 | 来源:发表于2019-03-01 16:26 被阅读0次

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:10 inSection:0];

    ClassRoomStyle2Cell *cell = [self.tableView cellForRowAtIndexPath:_selectIndex];

    有时候会出现cell获取为空的情况,是因为获取的指定cell必须已经显示在当前页面上了,也就是说已经被tableView创建了。
    如果还没被创建建议先调用

    [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];

    使tableView滚动到指定位置。

    相关文章

      网友评论

          本文标题:ios获取指定位置的cell

          本文链接:https://www.haomeiwen.com/subject/nyslbftx.html