searchDisplayController 引起的數(shù)組越界處理辦法
下面把searchDisplayController 引起的數(shù)組越界處理辦法給大家分享如下:
當(dāng)[searchDisplayController.searchResultsTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone] 時,發(fā)送了崩潰
錯誤提示如下:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]' *** First throw call stack: ( 0 CoreFoundation 0x000000010c6c6c65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010c35fbb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010c5bd17e -[__NSArrayI objectAtIndex:] + 190 3 UIKit 0x000000010d230fd2 -[UITableViewDataSource tableView:indentationLevelForRowAtIndexPath:] + 106 4 UIKit 0x000000010cdfb1b9 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 1711
查了好久才查到原因: 在錯誤log中有提示
3 UIKit 0x000000010d230fd2 -[UITableViewDataSource tableView:indentationLevelForRowAtIndexPath:] + 106 解決方法: -(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath { return 0; }
以上代碼就是針對searchDisplayController 引起的數(shù)組越界處理辦法的解決方案,希望對大家有所幫助。
相關(guān)文章
詳解iOS應(yīng)用使用Storyboard布局時的IBOutlet與IBAction
這篇文章主要介紹了iOS應(yīng)用使用Storyboard布局時的IBOutlet與IBAction,文中還附帶講解了為什么IBOutlet屬性是weak的,需要的朋友可以參考下2016-04-04理解iOS多線程應(yīng)用的開發(fā)以及線程的創(chuàng)建方法
這篇文章主要介紹了理解iOS多線程應(yīng)用的開發(fā)以及線程的創(chuàng)建方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-11-11iOS開發(fā)之topLayoutGuide和bottomLayoutGuide的使用小技巧分享
這篇文章主要給大家介紹了關(guān)于iOS開發(fā)之topLayoutGuide和bottomLayoutGuide使用的一些小技巧,需要的朋友可以參考下2017-11-11IOS關(guān)于大型網(wǎng)站搶購、距活動結(jié)束,剩余時間倒計時的實現(xiàn)代碼
這篇文章主要介紹了IOS關(guān)于大型網(wǎng)站搶購、距活動結(jié)束,剩余時間倒計時的實現(xiàn)代碼的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-08-08