你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS成長之路-獲取系統鍵盤的高度

iOS成長之路-獲取系統鍵盤的高度

編輯:IOS開發綜合
print?NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];       //UIKeyboardWillShowNotification鍵盤出現        [defaultCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];          //UIKeyboardWillHideNotification 鍵盤隱藏        [defaultCenter addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];      - (void)keyboardWillShow:(NSNotification *)aNotification   {       //獲取鍵盤的高度        NSDictionary *userInfo = [aNotification userInfo];       NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];       CGRect keyboardRect = [aValue CGRectValue];       int height = keyboardRect.size.width;   }     NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];     //UIKeyboardWillShowNotification鍵盤出現     [defaultCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];       //UIKeyboardWillHideNotification 鍵盤隱藏     [defaultCenter addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];   - (void)keyboardWillShow:(NSNotification *)aNotification {     //獲取鍵盤的高度 NSDictionary *userInfo = [aNotification userInfo];     NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];     CGRect keyboardRect = [aValue CGRectValue];     int height = keyboardRect.size.width; }  
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved