ios获取指定位置的cell

2019-03-01  本文已影响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滚动到指定位置。

上一篇下一篇

猜你喜欢

热点阅读