![](/img/trans.png)
[英]resignFirstResponder when UITextField on UIScrollView is not seen
[英]UITextField ResignFirstResponder crash on UIScrollView
所以我的问题是,我在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];
}
造成此消息崩溃的原因是:
*由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[[UIScrollView _isInUpdateAnimation]:无法识别的选择器发送到实例0x8f900e0'*第一次抛出调用堆栈
请帮助,tnq。
尝试这个。
[self.view endEditing:YES];
对于所有可能的文本字段/视图,应将第一响应者辞职。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.