所以我的问题是,我在 ViewController 中有一个 UIScrollView,我已将 childViewController 添加到此 ViewController,并将 childViewController View 添加到 UIScrollView(由容器 ViewController 管理)。childViewController 加载并将其 View 添加到parentViewController View 层次结构,childViewController 有一个 UITextField 作为 subview (在 xib 中组装 - IBOutlets 已连接并委托(delegate)) 然后我的 childViewController 中有这个方法:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touch recieved");
[self.textField resignFirstResponder];
}
这样做会导致崩溃并显示此消息:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIScrollView _isInUpdateAnimation]: unrecognized selector sent to instance 0x8f900e0' * First throw call stack
请帮忙,tnq。
最佳答案
试试这个。
[self.view endEditing:YES];
这应该为所有可能的文本字段/ View 辞去第一响应者。
关于ios - UITextField ResignFirstResponder 在 UIScrollView 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17613303/