#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偏移,从而在相同时间里做相同偏移量。
新闻热点
疑难解答