美文网首页移动端(android || ios)
iOS键盘按下完成和点击空白处隐藏软键盘

iOS键盘按下完成和点击空白处隐藏软键盘

作者: 螢火蟲的瘋狂 | 来源:发表于2018-01-19 11:39 被阅读0次

    -(void)viewDidLoad

    {

    self.view.userInteractionEnabled = YES;

    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerTapped:)];

    [self.view addGestureRecognizer:singleTap];

    }

    -(BOOL) textFieldShouldReturn:(UITextField *)textField {

    [textField resignFirstResponder];

    return YES;

    }

    -(void)fingerTapped:(UITapGestureRecognizer *)gestureRecognizer

    {

    [self.view endEditing:YES];

    }原文

    相关文章

      网友评论

        本文标题:iOS键盘按下完成和点击空白处隐藏软键盘

        本文链接:https://www.haomeiwen.com/subject/enjooxtx.html