我的代码遇到了奇怪的崩溃。
代码如下:
UIView *tableHeaderView = self.tableView.tableHeaderView;
CGRect frame = tableHeaderView.frame;
frame.size.height = 0;
tableHeaderView.frame = frame;
self.tableView.tableHeaderView = tableHeaderView;
崩溃发生在代码的最后一行。
然后,这是日志
Terminating app due to uncaught exception 'NSRangeException', reason:
'*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x345ae2a3 0x3c25397f 0x344f9b75 0x1a7055 0x363ebb8f 0x363d702b 0x363d7599 0x363d740d 0x3642b22b 0x1a0d77 0x363d5595 0x3642a14b 0x3642a091 0x36429f75 0x36429e99 0x364295d9 0x364294c1 0x364764d1 0x36428861 0x36428713 0x364a4399 0x364508fb 0x36691619 0x364a39b9 0x364a1fe7 0x26c8a1 0x221997 0x34ee96fd 0x34e291f9 0x34e29115 0x3428b45f 0x3428ab43 0x342b2fcb 0x344f474d 0x342b342b 0x3421703d 0x34583683 0x34582ee9 0x34581cb7 0x344f4ebd 0x344f4d49 0x380b82eb 0x3640a301 0x10819f 0x3c68ab20)
libc++abi.dylib: terminate called throwing an exception
我真的不知道我的代码发生了什么。
任何建议对我都有帮助!
谢谢。
最佳答案
你肯定在你的类中初始化了一些数组,首先通过放置 NSLog 检查你的数组它应该有一些值或者它是空的。我认为这就是他们制造问题的原因。
关于ios - 奇怪的 UITableView 崩溃 : NSRangeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20237888/