`
修博龙泉
  • 浏览: 312751 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

ios 文本框随着键盘高度变化而变化

 
阅读更多
监听键盘高度变化
   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasChange:) name:UIKeyboardDidChangeFrameNotification object:nil];

- (void)keyboardWasChange:(NSNotification *)aNotification {
    
    NSLog(@"Keyboard change");
    NSDictionary *info = [aNotification userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
    if (kbSize.height == 216) {
        NSLog(@"english");
        [UIView animateWithDuration:0.3f animations:^{
            CGRect curFrame=self.view.frame;
            curFrame.origin.y = viewFrameY -216.0;
            self.view.frame=curFrame;
        }];
    }
    else if(kbSize.height == 252){
        [UIView animateWithDuration:0.3f animations:^{
            CGRect curFrame=self.view.frame;
            curFrame.origin.y = viewFrameY -252.0;
            self.view.frame=curFrame;
        }];
        NSLog(@"中文");    
    }
    
    
}

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics