最近做長(zhǎng)按消息氣泡彈出menuController
刪除消息cell
功能遇到個(gè)錯(cuò)誤尿孔,libc++abi.dylib: terminate_handler unexpectedly threw an exception
咨跌,這個(gè)異常沒有打印日志,也無(wú)法定位到具體問(wèn)題。網(wǎng)絡(luò)找到這段代碼打印出異常:
@try {
//問(wèn)題代碼
[self.dataArray removeObjectAtIndex:1];
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:1 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
}
@catch (NSException *exception) {
NSLog(@"exception = %@", exception);
}
@finally {
}
輸出結(jié)果:
exception = Attempt to delete row containing first responder that refused to resign
看到這句話大概知道原因了,彈出menuController
需要設(shè)置becomeFirstResponder
成為第一響應(yīng)者,刪除cell
之前則需要resignFirstResponder
刪除cell
之前加上這段代碼就好使了:
MessageCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
[cell.messageView resignFirstResponder];