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

2016-11-06  本文已影响0人  amoyb1ooooooo

-(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{
    
}
上一篇下一篇

猜你喜欢

热点阅读