简体   繁体   English

UITextField ResignFirstResponder在UIScrollView上崩溃

[英]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: 所以我的问题是,我在ViewController中有一个UIScrollView,并且向此ViewController中添加了一个childViewController并将childViewController视图添加到UIScrollView中(由容器ViewController管理)。childViewController加载并将其视图添加到parentViewController视图中在层次结构中,childViewController有一个UITextField作为子视图(在xib中组装-IBOutlets也被连接和委托),然后在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 *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[[UIScrollView _isInUpdateAnimation]:无法识别的选择器发送到实例0x8f900e0'*第一次抛出调用堆栈

help please, tnq. 请帮助,tnq。

Try this. 尝试这个。

[self.view endEditing:YES];

That should resign first responder for all possible text fields/ views. 对于所有可能的文本字段/视图,应将第一响应者辞职。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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