我在使用这个应用程序(使用Storyboard)的侧边栏时遇到了一些问题。侧边栏是一个UITableViewController
,我希望顶部有一个搜索栏,所以我把Search Bar and Search Display Controller
对象放入了Storyboard。我有5个静态单元格中的边栏内容,搜索栏搜索远程数据库以检索结果。iOS - 在具有静态单元格的UITableViewController上使用UISearchDisplayController
我的问题是,如果我的搜索结果中包含超过5元,我得到以下错误:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
我不能完全肯定发生了什么幕后,但我相当肯定,尽管具有以下代码,但为Storyboard(5)中的表视图部分设置的行数覆盖了所有内容。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.searchDisplayController.searchResultsTableView) {
return [[self filteredCappegoryArray] count];
} else {
return [super tableView:tableView numberOfRowsInSection:0];
}
}
我会切换侧边栏使用动态细胞,但我的单元格包含一个容器视图和的XCode不会让我有在原型细胞的容器视图。我想知道是否有任何选择我必须解决此问题。
嗨真的很高兴你发布了这个'indentationLevelForRowAtIndexPath'修复程序。我一直在调试几个小时。 –
非常感谢您为此发布解决方案。我遇到了同样的问题,并且我花了几个小时调试问题。再次感谢! – Guerrix