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;
    }
    
  • 相关阅读:
    矩阵树定理
    随机乱搞算法
    数学
    BZOJ——3412: [Usaco2009 Dec]Music Notes乐谱
    BZOJ—— 3402: [Usaco2009 Open]Hide and Seek 捉迷藏
    洛谷—— P2884 [USACO07MAR]每月的费用Monthly Expense
    洛谷—— P2417 课程
    洛谷—— P1577 切绳子
    COGS 2598. 美丽的感觉
    10.23 模拟赛
  • 原文地址:https://www.cnblogs.com/ios988/p/5788228.html
Copyright © 2011-2022 走看看