---
title: "Can&#39;t Resign keyboard while tap on background?"  
description: "Can&#39;t Resign keyboard while tap on background?"  
author: "Anonymous User"  
published: 2015-07-21  
updated: 2015-07-22  
canonical: https://www.mindstick.com/forum/23362/can-39-t-resign-keyboard-while-tap-on-background  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Can&#39;t Resign keyboard while tap on background?

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to resign [keyboard](https://www.mindstick.com/forum/23117/android-soft-keyboard-close-hide) while [tap](https://answers.mindstick.com/qa/106164/tips-for-winning-in-mlb-tap-sports-baseball-2022) on [background](https://www.mindstick.com/articles/65/how-to-change-background-color-of-tab-control-in-c-sharp) 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](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)**

```
-(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];
  }
```

## Replies

### Reply by Tarun Kumar

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 }
```


---

Original Source: https://www.mindstick.com/forum/23362/can-39-t-resign-keyboard-while-tap-on-background

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
