简体   繁体   中英

UITextField ResignFirstResponder crash on UIScrollView

so my problem is this, i have an UIScrollView in a ViewController and i have added a childViewController to this ViewController and added the childViewController view to the UIScrollView (managed by the container ViewController) .the childViewController loads and its view is added to the parentViewController view hierarchy, the childViewController has a UITextField as a subview (assembled in xib - IBOutlets are connected and delegate as well) then i have this method in my childViewController:

  -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touch recieved");
     [self.textField resignFirstResponder];

}

what that does is causing a crash with this message:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIScrollView _isInUpdateAnimation]: unrecognized selector sent to instance 0x8f900e0' * First throw call stack

help please, tnq.

Try this.

[self.view endEditing:YES];

That should resign first responder for all possible text fields/ views.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM