ResignFirstResponder doesn't dismiss the keyboard (iPhone) -


I have searched through this site that I am not getting any solution to the problem which is facing it now Hope someone can help.

I have created a UIAlertView to prompt the user to enter their name in an iPhone app.

  UIAlertView * enterNameAlert = [[UIAlertView alloc] initWithTitle: otherButtonTitles canceled NSLocalizedString (, nil "or" @): @ "message" Enter your name: @ "\ n \ n \ N "Representative: self-cancelButtonTitle NSLocalizedString (@" OK ", not equal to), zero]; UITextField * enterNameField = [[UITextField alloc] initWithFrame: CGRectMake (16, 83, 252, 25)]; EnterNameField.keyboardAppearance = UIKeyboardAppearanceAlert; EnterNameField.borderStyle = UITextBorderStyleRoundedRect; EnterNameField.autocorrectionType = UITextAutocorrectionTypeNo; EnterNameField.clearButtonMode = UITextFieldViewModeWhile edit; EnterNameField.returnKeyType = UIReturnKeyDone; EnterNameField.delegate = self; [EnterNameField Be the FirstResponder]; [EnterNameAlert addSubview: enterNameField]; [Alarm alert show]; [EnterNameAlert release]; [Encrypted file release];  

I set up to comply with UITextFieldDelegate in this ViewController header file, and the applied is TextFieldShouldReturn:. keyboard when the user is trying to dismiss it hit

  - (bool) textFieldShouldReturn: (UITextField *) text field {if ([textfield isFirstResponder]) {[ Textfield resignFirstResponder]; NSLog (@ "text field was the first reply"); } And {{TextField Be the First Responder}; [TextField Resigns First Responder]; NSLog (@ "text field was not the first responder"); } NSLog (@ "textfieldshouldreturn"); Yes come back } In the Debugger, I confirm that this method is successfully called when I tap the completed button, at that time the Textfield was the first responder at that time. However, the keyboard does not go away, but a little clear button is removed. It is clear that textField is not the first reaction now, because when I click on the done button again, nothing was found. I just want to dismiss the keyboard with the finished button Can anyone offer a solution? million thanks. First of all, you need to define your  enterNameAlert  in the Interface title, after the text "itemprop =" text "> 

Then use the code below.

  - (zero) viewDidoadload {[Super Viewedload]; enterNameAlert = [[UIAlertView alloc] initWithTitle: @ message "Enter your name": @ "\ n \ n \ n" representative self cancelButtonTitle: Cancel NSLocalizedString (@ "or" nil) otherButtonTitles: NSLocalizedString (@ " OK ", not equal to), zero]; UITextField * enterNameField = [[UITextField alloc] initWithFrame: CGRectMake (16, 83, 252, 25)]; EnterNameField.keyboardAppearance = UIKeyboardAppearanceAlert; EnterNameField.borderStyle = UITextBorderStyleRoundedRect; EnterNameField.autocorrectionType = UITextAutocorrectionTypeNo; EnterNameField.clearButtonMode = UITextFieldViewModeWhile edit; EnterNameField.returnKeyType = UIReturnKeyDone; EnterNameField.delegate = self; [EnterNameAlert addSubview: enterNameField]; [EnterNameField Be the FirstResponder]; [Alarm alert show]; [Encrypted file release]; } - (BOOL) textFieldShouldReturn: (UITextField *) textField {if ([textField isFirstResponder]) {[textField resignFirstResponder]; [EnterNameAlert was rejected with the ButtonButton Index: 1 Animated: Yes]; [EnterNameAlert release]; NSLog (@ "text field was the first reply"); } And {{TextField Be the First Responder}; [TextField Resigns First Responder]; NSLog (@ "Text field was not the first responder"); } NSLog (@ "textfieldshouldreturn"); Yes come back }  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -