最近做长按消息气泡弹出menuController
删除消息cell
功能遇到个错误,libc++abi.dylib: terminate_handler unexpectedly threw an exception
,这个异常没有打印日志,也无法定位到具体问题。网络找到这段代码打印出异常:
@try {
//问题代码
[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 {
}
输出结果:
exception = Attempt to delete row containing first responder that refused to resign
看到这句话大概知道原因了,弹出menuController
需要设置becomeFirstResponder
成为第一响应者,删除cell
之前则需要resignFirstResponder
删除cell
之前加上这段代码就好使了:
MessageCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
[cell.messageView resignFirstResponder];
网友评论