我收到了一个包含很多依赖项的大应用程序。对于这种情况,我实现了一个名为RootTableViewController
的类来处理所有必须在每次需要表视图控制器时执行的操作。tableView numberOfRowsInSection在iOS4上调用tableView viewForHeaderInSection
现在我发现了一个无限循环,我不知道如何解决它。我在RootTableViewController
下面的代码:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
int numbersOfRowInSection = [self.tableView numberOfRowsInSection:section];
if (numbersOfRowInSection > 0)
{
// ...
}
else
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 28.0f)];
return view;
}
}
这完美的作品在iOS 5和iOS 6,但在iOS4的它会导致死循环,因为[tableView numberOfRowsInSection]
呼吁[tableView viewForHeaderInSection]
。我怎样才能解决这个使用表视图API?它没有解决方案,我与[ count]
的内部数据阵列工作,因为我有很多表视图控制器扩展此RootTableViewController
与不同的数据源。
这将工作。在大多数情况下,self.talbeView.dataSource和self.tableView.delegate将指向自己:) – 2013-03-19 19:08:30