使用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