我在 heightForRowAtIndexPath
内部调用 UITableView
委托(delegate)的 numberOfRowsInSection
方法,但它给了我一个错误访问错误:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
...
NSLog(@"number of rows in section: %i", [tableView numberOfRowsInSection:[indexPath section]]);
...
}
谁能告诉我这里出了什么问题?
最佳答案
您正在调用委托(delegate)方法。
当您调用此方法时,它会调用相关的委托(delegate)方法,如cellForRowAtIndexPath
、heightForRowAtIndexPath
等。
它会导致无限循环,这就是它崩溃的原因。
关于objective-c - iOS UITableView numberOfRowsInSection 错误访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13912540/