UITextfield how to make the keyboard never disappear from the screen?

1

I have a UITextField in an initial screen and I want the keyboard to appear up as soon as I start the view without having to click inside the UITextField box. When I press return I want you to do a check of the text typed with a string if it is the same the keyboard can go down or stay up. If the text is not the same the keyboard must remain uploaded, and allow me to re-enter another text. I also want to disable the keyboard hide key.

I currently have this code:

inside the ViewDidLoad: [self.textField becomeFirstResponder]

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

To check the text I do it in a - (IBAction) didEndPass and I do one thing or another.

    
asked by Popularfan 12.04.2017 в 00:34
source

1 answer

3

To make the keyboard appear uploaded, you must indicate it by making the textField become BecomeFirstResponder. I imagine you have a property pointing to that textField, with its assigned delegate. You will have something like this:

@property (strong, nonatomic) UITextField *textField;

In the viewWillAppear, you indicate that it is the firstResponder, then the keyboard will open

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.textField becomeFirstResponder];
}

To know when they give to the Enter, it is necessary to modify a little the function that you have written

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    if ( textField.text == "xxxxxxx" ) {
        [textField resignFirstResponder];
    } else {
        #mostrar el mensaje que quieras
    }
    return YES;
}
    
answered by 25.04.2017 / 19:17
source