1

I have three text fields in one view controller and when i do the method to dismiss the keyboard for all three text fields, the view controller doesn't come out.

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.namesuite.delegate = self;
    self.createpassword.delegate = self;
    self.createname.delegate = self;
    // Do any additional setup after loading the view.
}

I also have the textFieldShouldReturn function.

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

This is my button function to send me to the view controller that has the text fields.

- (IBAction)createaccount:(id)sender
{
    [self performSegueWithIdentifier:@"thirdsegue" sender:sender];
}
user3462406
  • 15
  • 1
  • 3
  • 7
  • Debugging to determine textFieldShouldReturn function is call when click return on the keyboard or not? – HoanNguyen Mar 27 '14 at 01:26
  • make sure you are confirming to both the UITextFieldDelegate and the UITextInputDelegate protocols – MrHaze Mar 27 '14 at 01:31
  • What do you mean by "the view controller doesn't come out"? – rmaddy Mar 27 '14 at 01:34
  • 4
    What do you mean by "dismiss all keyboards"? There is only ever one keyboard. – rmaddy Mar 27 '14 at 01:42
  • i have another view controller that when you click the button it goes into the new view controller, without the keyboard dismissal it segues into the next view but when i add the method for all text fields, the new view controller doesn't come out and it stops debugging. – user3462406 Mar 27 '14 at 05:00

3 Answers3

4

This will help. Try this:

[self.view endEditing:YES];

Hope this helps .. :)

Rashad
  • 11,057
  • 4
  • 45
  • 73
1

You should try this control (TPKeyboardAvoiding) and get ride of resign and scrolling issues. Its a generic solution.

NeverHopeless
  • 11,077
  • 4
  • 35
  • 56
0

Try:

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.namesuite resignFirstResponder];
    [self.createpassword resignFirstResponder];
    [self.createname resignFirstResponder];

    return YES;
}

or

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == self.namesuite)
    {
         [self.namesuite resignFirstResponder];
    }
    else if (textField == self.createpassword)
    {
         [self.createpassword resignFirstResponder];
    }
    else if (textField == self.createname)
    {
         [self.createname resignFirstResponder];
    }

return YES;
}
Gabriel.Massana
  • 8,165
  • 6
  • 62
  • 81