Помощь по UITextField - PullRequest
       3

Помощь по UITextField

0 голосов
/ 01 ноября 2010

Я новичок в разработке для iPhone.

У меня есть UITextField, в котором, когда я нажимаю клавишу ввода, мне нужно спрятать клавиатуру ...

любой способ сделать это ..

Спасибо за любую помощь и спасибо за ваше время

Ответы [ 4 ]

2 голосов
/ 01 ноября 2010
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
2 голосов
/ 01 ноября 2010

Реализация метода textFieldShouldReturn: протокола UITextFieldDelegate и возврат YES на основе переданного объекта.

- (BOOL) textFieldShouldReturn:(UITextField *) textField {
   [textField resignFirstResponder];
   return (textField == someTextField);
}
0 голосов
/ 03 мая 2012
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
0 голосов
/ 01 ноября 2010
  • (BOOL) textFieldShouldReturn: (UITextField *) textField { [textField resignFirstResponder]; вернуть ДА; }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...