Skip to content

Instantly share code, notes, and snippets.

@syxc
Forked from huobazi/UITextField+HideKeyBoard.h
Created February 21, 2013 05:40
Show Gist options
  • Save syxc/5002452 to your computer and use it in GitHub Desktop.
Save syxc/5002452 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
@interface UITextField (HideKeyBoard)
-(void)hideKeyBoard:(UIView *)view;
@end
#import "UITextField+HideKeyBoard.h"
@implementation UITextField (HideKeyBoard)
- (void) hideKeyBoard:(UIView*)view{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(doHideKeyBoard)];
tap.numberOfTapsRequired = 1;
[view addGestureRecognizer: tap];
[tap setCancelsTouchesInView:NO];
[tap release];
}
- (void)doHideKeyBoard{
[self resignFirstResponder];
}
@end
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.txtValue hideKeyBoard:self.view];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment