[在UITextField中按Enter时隐藏键盘

问题描述 投票:0回答:4

我是iPhone开发的新手。

我有一个UITextField,当我按Enter时,我需要隐藏键盘。

任何实现此目的的方法?

iphone iphone-sdk-3.0
4个回答
2
投票

实现UITextFieldDelegate协议的UITextFieldDelegate方法,并根据传入的对象返回textFieldShouldReturn:

YES

2
投票
- (BOOL) textFieldShouldReturn:(UITextField *) textField {
   [textField resignFirstResponder];
   return (textField == someTextField);
}

0
投票
  • (BOOL)textFieldShouldReturn:(UITextField *)textField{[textField resignFirstResponder];返回是;}

0
投票
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
© www.soinside.com 2019 - 2024. All rights reserved.