美文网首页
ios textField 、textView辞去第一响应者键盘

ios textField 、textView辞去第一响应者键盘

作者: amoyb1ooooooo | 来源:发表于2016-11-06 21:48 被阅读0次
    
    -(BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        return true;
    }
    
    -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
        if ([text isEqualToString:@"\n"]) {
            [textView resignFirstResponder];
            return false;
        }
        return true;
    }
    
    - (void)viewWillDisappear:(BOOL)animated{
        // 注销键盘出现通知
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
        //注销键盘隐藏通知
        [[NSNotificationCenter defaultCenter]removeObserver:self name:UIKeyboardDidHideNotification object:nil];
        [super viewWillDisappear:animated];
    }
    
    - (void)keyboradDidShow:(NSNotification*)notif{
        
    }
    
    - (void)keyboradDidHide:(NSNotification*)notif{
        
    }
    

    相关文章

      网友评论

          本文标题:ios textField 、textView辞去第一响应者键盘

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