#pragma mark - reg & unreg notification
- (void)regNotification{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];}- (void)unregNotification{ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];}#pragma mark - notification handler- (void)keyboardWillChangeFrame:(NSNotification *)notification{ NSDictionary *info = [notification userInfo]; CGFloat duration = [[info objectForKey:UIKeyboardAnimationDuration通過獲取鍵盤消息的開始狀態、結束狀態,以及變化周期,可以計算出具體的Y偏移,從而在相同時間里做相同偏移量。
新聞熱點
疑難解答