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;
    }
    
  • 相关阅读:
    SQL CHECKOUT
    Adobe CS4 " Licensing for this product has expired " FIX!!!
    sizeof()用法汇总
    Command
    EXP_FULL_DATABASE,IMP_FULL_DATABASE,DBA,CONNECT,RESOURCE
    inet_addr函数处理IP地址需要注意的问题 (转)
    Oracle:外键关联导致数据无法删除
    三范式
    Wireshark界面上展开数据帧
    我的HTML学习记录(三)
  • 原文地址:https://www.cnblogs.com/ios988/p/5788228.html
Copyright © 2011-2022 走看看