开发者

Objective C: ResignFirstResponder with a button

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜