UITextField上的帮助

时间:2010-11-01 03:04:35

标签: iphone iphone-sdk-3.0

我是iPhone开发的新手。

我有一个UITextField,当我按下输入时我需要隐藏键盘......

任何方式来实现这一目标..

感谢您的帮助和感谢您的时间

4 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:2)

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

答案 2 :(得分:0)

  • (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; 返回YES; }

答案 3 :(得分:0)

First if the textfield global object is myTextField then <br>

In .h file <br> 

@interface MyScreen : UIViewController <**UITextFieldDelegate**>
{
     UITextField *myTextField;
}
@property (nonatomic,retain) IBOutlet UITextField ***myTextField**;<br>

In .xib <br>

Attach myTextField to the control.<br>

In .m File <br>



- (void) viewDidLoad<br>
{

       [super viewDidLoad];
       myTextField.delegate = self;
}

If you want to return the keyboard on particular return button of keyboard press: <br>

#pragma mark  UITextFieldDelegate

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

If you want to return on your particular button <br>

- (IBAction) myButtonPressed:(id)sender
{
        [self.myTextField resignFirstResponder];
}


Apologise for my bad english.

Thanks & Regards,
Gautam Tiwari
Ios Application Developer