zoukankan      html  css  js  c++  java
  • iOS开发中的键盘高度变化处理

    - (void)viewWillDisappear:(BOOL)animated

    {

    [[NSNotificationCenterdefaultCenter] removeObserver:selfname:UIKeyboardWillShowNotificationobject:nil];

    [[NSNotificationCenterdefaultCenter] removeObserver:selfname:UIKeyboardWillHideNotificationobject:nil];

    }

    - (void)viewDidLoad

    {

        [superviewDidLoad];

        

        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotificationobject:nil];

        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotificationobject:nil];

        

     }

    #pragma mark -

    #pragma mark Responding to keyboard events

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

        [self keyboardWillShowHide:notification];

    }

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

        [self keyboardWillShowHide:notification];

    }

    - (void)keyboardWillShowHide:(NSNotification *)notification

    {

        CGRect keyboardRect = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

    //UIViewAnimationCurve curve = [[notification.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];

    double duration = [[notification.userInfoobjectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];

        

        

        CGFloat keyboardY = [self.view convertRect:keyboardRect fromView:nil].origin.y;

        

        

        NSLog(@"keyboardY :%f",keyboardY);

        

        [UIViewanimateWithDuration:duration

                              delay:0.0f

                            options:UIViewAnimationOptionCurveEaseInOut//[UIView animationOptionsForCurve:curve]

                         animations:^{

                             CGFloat keyboardY = [self.view convertRect:keyboardRect fromView:nil].origin.y;

                             CGFloat keyboardH = [self.view convertRect:keyboardRect fromView:nil].size.height;

                             

                             imgUpload.frame = CGRectMake(5+33, keyboardY-33, 33, 33);

                             imgURL.frameCGRectMake(5, keyboardY-33, 33, 33);

                             

                             NSLog(@"keyboardY   %f",keyboardH);

                         }

                         completion:^(BOOL finished) {

                         }];

    }

  • 相关阅读:
    linux下文件编码转换
    linux下打开文件数
    从hive0.7.1升级到hive0.8.1
    hive使用过程中碰到的问题
    JVM和GC
    代码生成器开发设计
    开源代码生成器:SmartCode [转]
    byte与其他类型的转换
    测试版天思.net代码生成器
    [源码试]写xml的解析器
  • 原文地址:https://www.cnblogs.com/StevenFu/p/3133635.html
Copyright © 2011-2022 走看看