当前位置: 移动技术网 > 移动技术>移动开发>IOS > searchDisplayController 引起的数组越界处理办法

searchDisplayController 引起的数组越界处理办法

2019年07月24日  | 移动技术网移动技术  | 我要评论

下面把searchdisplaycontroller 引起的数组越界处理办法给大家分享如下:

当[searchdisplaycontroller.searchresultstableview setseparatorstyle:uitableviewcellseparatorstylenone] 时,发送了崩溃

错误提示如下:

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 引起的数组越界处理办法的解决方案,希望对大家有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网