【发布时间】:2011-07-02 16:03:37
【问题描述】:
我有 2 个函数可以 resignFirstResponder,但是当文本字段在滚动视图中时它们都不起作用
我的功能:
-(BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == textField1) {
[textField1 resignFirstResponder];
}
if (theTextField == textField2) {
[textField2 resignFirstResponder];
}
if (theTextField == textField3) {
[textField3 resignFirstResponder];
}
return YES;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
[textField1 resignFirstResponder];
[textField2 resignFirstResponder];
[textField3 resignFirstResponder];
}
我已经在 IB 中链接了滚动视图,我不知道为什么只有当我在滚动视图之外单击时它才在那里不起作用。所以它只响应视图,但是为什么?我认为 [[event allTouches] anyObject] 响应 ALLtouches在任何对象
感谢您的帮助
【问题讨论】:
标签: objective-c cocoa-touch uiscrollview uitouch