Attempt to delete row containing first responder that refused to resign

坚强是说给别人听的谎言 提交于 2019-12-01 05:53:55

I've never seen that message before, but my immediate impulse if I were to see it would be: try delayed performance. Even something as simple as this might be an interesting experiment:

dispatch_async(dispatch_get_main_queue(), ^{
    [self.tableView deleteRowsAtIndexPaths:@[indexPath] 
     withRowAnimation:UITableViewRowAnimationAutomatic];
});

My thought here is, let's not try to delete the row while the text field is still reporting in (i.e. while textFieldEditingDidEnd is still running); let's give the runloop a chance to finish its cycle.

Ashokkumar.S S

i am also faced the same problem. while keyboard is present you need to call resignFirstResponder first then call UITableview reload method after

(void)textFieldDidEndEditing:(UITextField *)textField

delegate method executed or inside:

(void)textFieldDidEndEditing:(UITextField *)textField{
    [tableview reloadData];
}

My crash was from an editable UIWebView inside of a UICollectionViewCell. The following fixed it:

[self.view endEditing:YES]

I came across the same NSInternalInconsistencyException exception. My solution was the following:

textView.selectedTextRange = nil;    // clear the selected text
[textView resignFirstResponder];

Got this error when removing a UITableViewCell that contained a UITextView from a keyboard hide UIKeyboardWillHideNotification notification.

Fix was to move the logic into UIKeyboardDidHideNotification

I came across this issue when my method textFieldShouldEndEditing was returning NO in some situations

I also experienced the the same problem. Even though after calling "resignFirstResponer" and "endEditing" , It is found to be crashing.

When I tried with @matt's approach , it is working fine. Thanks matt.

It seems like since we are adding the "deleteRowsAtIndexPaths:" into the GCD queue , the queue will make sure that the previous task is completed in the queue and then only start the next task in the main_queue. Hence no need to add any delay.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!