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

ios 键盘弹起

时间:2015-09-23 18:43:35      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

#pragma mark 键盘弹起操作

- (void)keyboardWillShow:(NSNotification *)notification
{
    NSDictionary *info = notification.userInfo;
    kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
    [UIView beginAnimations:@"kbmove" context:nil];
    [UIView setAnimationDelay:0.5];
    if (!iPhone5) {
        
        self.view.frame = CGRectMake(0, 0 - kbSize.height + 150, SCREEN_WIDTH, SCREEN_HEIGHT);
        
    }else
    {
        self.view.frame = CGRectMake(0, 0 - kbSize.height + 120, SCREEN_WIDTH, SCREEN_HEIGHT);
    }
    [UIView commitAnimations];
}

#pragma mark 键盘消失操作

- (void)keyboardwillhidden:(NSNotification *)notification
{
    self.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}

- (void)createKeyboardNotification
{
    //键盘通知
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardwillhidden:)
                                                 name:UIKeyboardWillHideNotification object:nil];
}

ios 键盘弹起

标签:

原文地址:http://www.cnblogs.com/A--G/p/4832803.html

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