开发者

Objective C: ResignFirstResponder with a button

开发者 https://www.devze.com 2023-01-30 15:27 出处:网络
Is 开发者_JAVA技巧there a way for a UIButton to trigger resignFirstResponder? I have my program set to do so in a function when you tap outside of a textfield, but I want the keyboard to go away when

Is 开发者_JAVA技巧there a way for a UIButton to trigger resignFirstResponder? I have my program set to do so in a function when you tap outside of a textfield, but I want the keyboard to go away when the user hits the submit button.

This is what I have for the UITextFields

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
 [x1 resignFirstResponder];
 [x2 resignFirstResponder];
 [y1 resignFirstResponder];
 [y2 resignFirstResponder];
}


Given the existence of the method you mention, how about:

- (IBAction)solve:(id)sender {
   [x1 resignFirstResponder];
   [x2 resignFirstResponder];
   [y1 resignFirstResponder];
   [y2 resignFirstResponder];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号