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) {

                         }];

    }

  • 相关阅读:
    A working example of bad SQL statement causes too much CPU usage
    Notes on <<Refactoring Databases Evolutionary Database Design>>
    DBMS_SQL & ORA01000: Too many open cursors
    TTS, not used for schema exp/imp
    Notes on <High Performance MySQL> Ch6: Optimizing Server Settings
    Notes on <High Performance MySQL> Ch3: Schema Optimization and Indexing
    A bug of "sql*loader"?
    11.2.0.2 improves the support for MERGE statement
    Use "OR" in SQL with caution
    关于NORFLASH和NANDfLASH的区别。——Arvin
  • 原文地址:https://www.cnblogs.com/StevenFu/p/3133635.html
Copyright © 2011-2022 走看看