【问题标题】:Crash in tableview cell表格视图单元格中的崩溃
【发布时间】:2011-10-16 09:54:19
【问题描述】:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 18 beyond bounds [0 .. 16]'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x02b11b99 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x02c6140e objc_exception_throw + 47
    2   CoreFoundation                      0x02b07695 -[__NSArrayM objectAtIndex:] + 261
    3   MyPocket                            0x0005efe9 -[loginLocalitems tableView:didSelectRowAtIndexPath:] + 638
    4   UIKit                               0x00be9a48 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
    5   UIKit                               0x00be032e -[UITableView _userSelectRowAtIndexPath:] + 219
    6   Foundation                          0x0037821a __NSFireDelayedPerform + 441
    7   CoreFoundation                      0x02af2f73 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
    8   CoreFoundation                      0x02af45b4 __CFRunLoopDoTimer + 1364
    9   CoreFoundation                      0x02a50dd9 __CFRunLoopRun + 1817
    10  CoreFoundation                      0x02a50350 CFRunLoopRunSpecific + 208
    11  CoreFoundation                      0x02a50271 CFRunLoopRunInMode + 97
    12  GraphicsServices                    0x03f4e00c GSEventRunModal + 217
    13  GraphicsServices                    0x03f4e0d1 GSEventRun + 115
    14  UIKit                               0x00b84af2 UIApplicationMain + 1160
    15  MyPocket                            0x000023d2 main + 84
    16  MyPocket                            0x00002375 start + 53
    17  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'

上述数组的原因是什么。仅当我选择表格视图的下部单元格时才会出现此崩溃任何人请帮助

【问题讨论】:

  • didSelectRowAtIndexPath:发布您的代码

标签: iphone ios4 iphone-sdk-3.0 cocos2d-iphone ios-simulator


【解决方案1】:

这个错误告诉你你的 NSMutableArray 里面只有 0 到 16 个对象。当您滚动到表格底部并选择较低的单元格时,您正试图访问数组中索引高于 16 的对象。因此请尝试检查您用于表格的数组是否已正确填充,并且您以后不会从中删除某些内容。

【讨论】:

    【解决方案2】:

    您正在从可变数组加载数据? 检查数组是否真的有 18 个元素。 或者如果您在 numberOfRows inSection 方法中给出的数字大于实际行数

    这是一个范围异常:

    index 18 beyond bounds [0 .. 16]
    

    如您所见,它仅在您单击下方项目时发生

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多