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;
    }
    
  • 相关阅读:
    第三方模块加载时出现XXX运行 提示错误:无法加载文件 C:UsersgxfAppDataRoaming pmXXX.ps1,因为在此系统上禁止运行脚本。
    node模块化
    前端面试集锦
    将字符转换成驼峰表示法
    JavaScript数据处理
    大数据基础整合
    移动端网页特效
    本地存储
    DOM重点核心
    触发器SQL
  • 原文地址:https://www.cnblogs.com/ios988/p/5788228.html
Copyright © 2011-2022 走看看