CAN'T RESIGN KEYBOARD WHILE TAP ON BACKGROUND?

Jayne Spooner

Total Post:21

Points:147
Posted by  Jayne Spooner
 620  View(s)
Ratings:
Rate this:

I am trying to resign keyboard while tap on background but I cann't

 

first I have clicked on editable textfield and open keyboard then I have cliked on another textfield that is not editable after that I have cliked background but I cann't resign keyboard

 

here is my code

-(void)textFieldDidBeginEditing:(UITextField *)textField

 {

if(textField == insertcity)

{

    [self.view endEditing:YES];

    citytable.hidden = NO;

    hoteltable.hidden = YES;

    [self SetDynamicHieghtofTbl:citytable andArr:cityarray];

}

if(textField == inserthotel)

{

[self.view endEditing:YES];

  hoteltable.hidden = NO;

  citytable.hidden = YES;

  [self SetDynamicHieghtofTbl:hoteltable andArr:hotelarray];

 }

 if(self.txt_validationCode.tag == 3)    {       //[self.view endEditing:NO];

    }

}

-(void)textFieldDidEndEditing:(UITextField *)textField

{

   [textField resignFirstResponder];

   if(textField.tag == 3)

   {

    self.enteredCode = textField.text;

   }

}

-(void) backgroundTap: (UITapGestureRecognizer *)recognizer

{

    citytable.hidden = YES;

    hoteltable.hidden = YES;

    [self.txt_validationCode resignFirstResponder];

  }

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Can't Resign keyboard while tap on background?

    try this or remove the tap gesture and add the following method


    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 

    [self textFieldResign];

    }

    -(void)textFieldResign{

    [self.txt_validationCode resignFirstResponder];

    [self.view endEditing:YES];

    // whatever you want use here

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!