iOS点击键盘以外空白区域隐藏键盘的常见方法

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
    tapGr.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tapGr];
}
-(void)viewTapped:(UITapGestureRecognizer*)tapGr
{
    [textfield resignFirstResponder];
}
http://www.cnblogs.com/jaenson/archive/2013/03/12/iOS_Keybroad_Hide.html

你可能感兴趣的:(iOS点击键盘以外空白区域隐藏键盘的常见方法)