My application crashes and showing the error below.
Thread 0 Crashed:
0 libobjc.A.dylib 0x3b5d7b26 objc_msgSend + 6
1 UIKit 0x339c74f4 -[UIResponder(Static) _setFirstResponder:] + 40
2 UIKit 0x339c74f4 -[UIResponder(Static) _setFirstResponder:] + 40
3 UIKit 0x339b3000 -[UIResponder resignFirstResponder] + 248
4 UIKit 0x339e4e9c -[UITableView reloadData] + 224
5 CSModule 0x001588e2 -[UIBubbleTableView reloadData]
I try to fix issue but did not get solution. Please help me to fix the issue.
I am have created a custom view with a label to on table cellview, when we tap on that custom view , it show a UIMenuController with copy option. My custom view handle tap gesture as below
-(void) handleTapGesture:(UIGestureRecognizer*) recognizer{
if (self.window == nil) {
NSLog(@" \n\n\n\n Window is null \n\n\n\n\n\n");
return;
}
[self becomeFirstResponder];
CGRect targetRectangle = CGRectMake(self.bounds.size.width/2, 2, 2, 2);
UIMenuController *menuController = [UIMenuController sharedMenuController];
[menuController setTargetRect:targetRectangle inView:self];
[menuController setMenuVisible:YES animated:YES];
}
If I did not handle tap gesture and do not show this UIMenuController , then it does not produce any crashes.
Crashes occurs randomly , I have implement Pull to refresh in UITableView, on pull I download previous data from server and reload tableview, at the same time I tap on the custom view in cell, some time crashes occurs.
One more thing some time crashes occurs at handleTapGesture function as bellow.
Thread 0 Crashed:
0 libobjc.A.dylib 0x3b5d7b26 objc_msgSend + 6
1 UIKit 0x339c74f4 -[UIResponder(Static) _setFirstResponder:] + 40
2 UIKit 0x339c74f4 -[UIResponder(Static) _setFirstResponder:] + 40
3 UIKit 0x339c74f4 -[UIResponder(Static) _setFirstResponder:] + 40
4 UIKit 0x339b2f92 -[UIResponder resignFirstResponder] + 138
5 UIKit 0x3398d958 -[UIResponder becomeFirstResponder] + 308
6 UIKit 0x3398dc46 -[UIView(Hierarchy) becomeFirstResponder] + 102
7 CSModule 0x0006ceb2 -[UIChatFootageTextView handleTapGesture:]
Please If you have any idea to fix the issue , then please help me to fix it.
Previously, I was getting the crash issue. As per my idea, since I was setting my custom view as first responder to show UIMenuController, that was required to visible UIMenuController. So I can't remove that statement.
To fix this, I resign to it as first responder just after the UIMenuController set as visible. Now my application does not get that random crashes.
-(void) handleTapGesture:(UIGestureRecognizer*) recognizer{
if (self.window == nil) {
NSLog(@" \n\n\n\n Window is null \n\n\n\n\n\n");
return;
}
[self becomeFirstResponder];
CGRect targetRectangle = CGRectMake(self.bounds.size.width/2, 2, 2, 2);
UIMenuController *menuController = [UIMenuController sharedMenuController];
[menuController setTargetRect:targetRectangle inView:self];
[menuController setMenuVisible:YES animated:YES];
[self resignFirstResponder];
}