我在使用這個應用程序(使用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