我有一个项目使用 rectForRowAtIndexPath 从单元格获取帧,但是当我在 iOS8 模拟器上构建时,帧返回 0,但在 iOS7 模拟器中它工作正常。
有人遇到过同样的问题吗?
谢谢!
最佳答案
如果 tableView 没有完成加载,cell 不可见,则 rectForRowAtIndexPath
返回 0。
尝试延迟 0.1 秒或更长时间,像这样:
[self.tableView reloadData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
CGRect cellFrame = [tableView rectForRowAtIndexPath:indexPath];
}];;
});
关于uitableview - rectForRowAtIndexPath 不适用于 iOS8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25997711/