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;
    }
    
  • 相关阅读:
    如何通过地址转换为WGS经纬度
    Oracle动态创建时间分区,以及Oracle12c中快速创建自增列
    asp.net微信jsapi支付
    asp.net关于如何准许api跨域访问
    ajax调用天气接口
    git补充(命令)转自https://github.com/Wasdns/github-example-repo
    git补充(关于pull request)转自知乎
    Linux基础笔记
    git前期准备
    MVC设计模式
  • 原文地址:https://www.cnblogs.com/ios988/p/5788228.html
Copyright © 2011-2022 走看看