使用iPhone模拟器2.2.1iPhone应用程序冻结
使用表格并希望将复选标记添加到所选单元格。
我从一个应用程序中添加了这段代码,该应用程序可以工作到不同的应用程序,但使用同样的方法。现在,这个新代码编译并启动,并在选定的单元格中打上复选标记,几秒钟后程序冻结。
*此代码部分来自一个工作应用程序。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
***This snippet was added (from another working app)
if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryCheckmark)
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone];
else
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
[self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f];
***End of snippet
}
我为控制台放置了一些printf语句,执行过程通过if语句并通过最后一行。
所以它没有代码片段,如果我包含它编译,启动的代码片段,并且在选择一个项目并且出现复选标记后,应用程序会冻结。
控制台的错误消息如下。
*** -[RootViewController deselect]: unrecognized selector sent to instance 0x526750
2011-04-16 16:15:30.132 lab3[37268:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[RootViewController deselect]: unrecognized selector sent to instance 0x526750'
可能重复的[NSInvalidArgumentException](http://stackoverflow.com/questions/726727/nsinvalidargumentexception) – Caleb 2011-04-16 21:20:01
它真的有帮助,如果你实际上读取错误信息说(什么时候考虑你复制的代码) 。 – Eiko 2011-04-16 21:33:03