iOS app “next” key won't go to the next text field

前端 未结 11 2535
栀梦
栀梦 2020-12-12 21:32

I have a simple scene (using storyboard in IB) with a Username and Password text box. I\'ve set the keyboard to close when you are on the Password text field but can\'t get

11条回答
  •  星月不相逢
    2020-12-12 22:00

    Here's what you would put:

    - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
        if (theTextField == self.textPassword) {
            [theTextField resignFirstResponder];
        } else if (theTextField == self.usernameField) {
            [self.textPassword becomeFirstResponder];
        }
    return YES;
    }
    

提交回复
热议问题