现在的位置: 首页 > 综合 > 正文

点击视图上任意位置回收键盘的方法(添加手势)

2014年04月05日 ⁄ 综合 ⁄ 共 528字 ⁄ 字号 评论关闭

先说一下我的视图现在的结构

控制器的view上添加有textView ,textField,点击弹出键盘后,点击视图的其他位置,让键盘回收.

---------------------------------------------------------------------------------------------------------------------------------------------------------

//在点击需要收回键盘的视图添加单击手势

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(reKeyBoard)];

    [self.view addGestureRecognizer:tap];

//实现方法//取消textView ,textField的第一响应者即可

- (void)reKeyBoard
{
    [_introduceGroupField resignFirstResponder];
    [_nameGroupField resignFirstResponder];

}

抱歉!评论已关闭.