码迷,mamicode.com
首页 > 移动开发 > 详细

iOS——UIKeyboardWillShowNotification 监听键盘高度变化

时间:2015-05-30 10:39:54      阅读:3367      评论:0      收藏:0      [点我收藏+]

标签:

- (void)viewDidLoad {

    [super viewDidLoad];

    UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 100, 50)];

    textField.backgroundColor = [UIColor blueColor];

    [self.view addSubview:textField];

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

 

    };

 

-(void)keyboardWillShow:(NSNotification*)notification{

    NSDictionary*info=[notification userInfo];

    CGSize kbSize=[[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;

    NSLog(@"keyboard changed, keyboard width = %f, height = %f",

          kbSize.width,kbSize.height);

    //在这里调整UI位置

}

iOS——UIKeyboardWillShowNotification 监听键盘高度变化

标签:

原文地址:http://www.cnblogs.com/AlienY/p/4539931.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!