WEB开发网
开发学院手机开发iPhone 开发 ios点击键盘以外空白区域隐藏键盘 阅读

ios点击键盘以外空白区域隐藏键盘

 2012-09-06 13:59:27 来源:WEB开发网   
核心提示: 在view上添加一个UITapGestureRecognizer- (void)viewDidLoad{[super viewDidLoad];UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc] initWithTarget:self act

 在view上添加一个UITapGestureRecognizer
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
tapGr.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:tapGr];
}
-(void)viewTapped:(UITapGestureRecognizer*)tapGr{
[activitySearchBar resignFirstResponder];
}

Tags:ios 点击 键盘

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接