A Category for UIViewController that can easily manage keyboard response.
在viewWillAppera
中添加如下方法
[self addObserveKeyboardWithAnimation:^(id controller, CGFloat targeMoveViewEndTop, CGFloat offset, NSString *const notification) {
// your code
}];
在 viewWillDisappear
中添加 [self removeObservKeyboard];
targetMoveView: 在键盘将要弹出或者收回时,被移动的view referView: referView.top 会与 keyboard.top 进行对比,以决定targetMoveView是否真的需要移动
add follow code in viewWillAppear
[self addObserveKeyboardWithAnimation:^(id controller, CGFloat targeMoveViewEndTop, CGFloat offset, NSString *const notification) {
// your code
}];
add [self removeObservKeyboard];
in viewWillDisappear
targetMoveView: the view that view move when keyboard show or hide referView: referView.top will compare to the keyboard.top to determine whether targetMoveView should be moved