Created
November 19, 2010 03:12
-
-
Save jacoblyles/706078 to your computer and use it in GitHub Desktop.
Method to hide keyboard when background tapped
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ | |
for (UITouch *touch in touches){ | |
if (touch.view == self.view){ | |
[self findAndResignFirstResponder]; | |
} | |
} | |
} | |
-(void)findAndResignFirstResponder{ | |
for (UIView *aView in [self.view subviews]){ | |
if ([aView isFirstResponder] ) { | |
[aView resignFirstResponder]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment