When I tap the go button on the keyboard I push to a new view controller, but for a split second on the new view controller the old keyboard is still showing, how can I resign the keyboard so it doesn't appear on the new view controller I have tried both
[self.view endEditing:YES];
And this
[_passwordField resignFirstResponder];
in the prepareForSegue
method and the same two lines in the IBAction
I think you have first tying to push to a new view controller, after that you are code for hide keyboard. Use following code for your problem, use this delegate method textFieldShouldReturn .
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
if ( textField == _passwordField){
[_passwordField resignFirstResponder];
//After that Push to a new view controller From Here
}
return TRUE;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.