Я новичок в разработке для iPhone.
У меня есть UITextField, в котором, когда я нажимаю клавишу ввода, мне нужно спрятать клавиатуру ...
любой способ сделать это ..
Спасибо за любую помощь и спасибо за ваше время
- (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; }
Реализация метода textFieldShouldReturn: протокола UITextFieldDelegate и возврат YES на основе переданного объекта.
textFieldShouldReturn:
UITextFieldDelegate
YES
- (BOOL) textFieldShouldReturn:(UITextField *) textField { [textField resignFirstResponder]; return (textField == someTextField); }
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