zoukankan      html  css  js  c++  java
  • iOS键盘出现时界面跟着往上推

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    
    #pragma mark 键盘即将显示
    - (void)keyBoardWillShow:(NSNotification *)note{
        
        CGRect rect = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
        CGFloat ty = rect.size.height;
        [UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
            self.view.transform = CGAffineTransformMakeTranslation(0, - ty + 170);
        }];
        
    }
    #pragma mark 键盘即将退出
    - (void)keyBoardWillHide:(NSNotification *)note{
        
        
        [UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
            self.view.transform = CGAffineTransformIdentity;
        }];
    }
    
    
    
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        if (![self.remarkTextView isExclusiveTouch]||(![self.remarkTextView isExclusiveTouch])) {
           
            [self.remarkTextView resignFirstResponder];
            [self.qqTextField resignFirstResponder];
          
        }
    }
    
    - (BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        return YES;
    }
    
    
    -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
        
        if([text isEqualToString:@"
    "]){
            
            [textView resignFirstResponder];
            
            return NO;
        }
        
        return YES;
    }
    
  • 相关阅读:
    基础语法
    Python简介
    Linux安装Python
    Git安装和使用
    vue 表单验证省市县三联动
    js 异步问题
    Json对象与Json字符串互转(4种转换方式)
    vue 常用的表单验证,包括手机号码,固定电话和身份证...
    webpack 基本功能和原理
    测试build出来的dist文件夹是否编译成功
  • 原文地址:https://www.cnblogs.com/ios988/p/5788228.html
Copyright © 2011-2022 走看看