键盘遮挡
2015-05-13 20:38
288 查看
- (void)viewWillAppear:(BOOL)animated
{
[super
viewWillAppear:animated];
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super
viewDidDisappear:animated];
[[NSNotificationCenter
defaultCenter] removeObserver:self
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter
defaultCenter] removeObserver:self
name:UIKeyboardWillHideNotification
object:nil];
}
- (void)keyboardWillShow:(NSNotification *)aNotification
{
CGRect keyboardRect = [[[aNotification
userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey]
CGRectValue];
NSTimeInterval animationDuration = [[[aNotification
userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey]
doubleValue];
CGRect frame =
comfirmPaymentTableView.frame;
frame.size.height -= keyboardRect.size.height;
[UIView
beginAnimations:@"ResizeForKeyboard"
context:nil];
[UIView
setAnimationDuration:animationDuration];
comfirmPaymentTableView.frame = frame;
[UIView
commitAnimations];
}
- (void)keyboardWillHide:(NSNotification *)aNotification
{
CGRect keyboardRect = [[[aNotification
userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]
CGRectValue];
NSTimeInterval animationDuration = [[[aNotification
userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey]
doubleValue];
CGRect frame =
comfirmPaymentTableView.frame;
frame.size.height += keyboardRect.size.height;
[UIView
beginAnimations:@"ResizeForKeyboard"
context:nil];
[UIView
setAnimationDuration:animationDuration];
comfirmPaymentTableView.frame = frame;
[UIView
commitAnimations];
}
{
[super
viewWillAppear:animated];
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super
viewDidDisappear:animated];
[[NSNotificationCenter
defaultCenter] removeObserver:self
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter
defaultCenter] removeObserver:self
name:UIKeyboardWillHideNotification
object:nil];
}
- (void)keyboardWillShow:(NSNotification *)aNotification
{
CGRect keyboardRect = [[[aNotification
userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey]
CGRectValue];
NSTimeInterval animationDuration = [[[aNotification
userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey]
doubleValue];
CGRect frame =
comfirmPaymentTableView.frame;
frame.size.height -= keyboardRect.size.height;
[UIView
beginAnimations:@"ResizeForKeyboard"
context:nil];
[UIView
setAnimationDuration:animationDuration];
comfirmPaymentTableView.frame = frame;
[UIView
commitAnimations];
}
- (void)keyboardWillHide:(NSNotification *)aNotification
{
CGRect keyboardRect = [[[aNotification
userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]
CGRectValue];
NSTimeInterval animationDuration = [[[aNotification
userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey]
doubleValue];
CGRect frame =
comfirmPaymentTableView.frame;
frame.size.height += keyboardRect.size.height;
[UIView
beginAnimations:@"ResizeForKeyboard"
context:nil];
[UIView
setAnimationDuration:animationDuration];
comfirmPaymentTableView.frame = frame;
[UIView
commitAnimations];
}
相关文章推荐
- 『零行代码』解决键盘遮挡问题(iOS)
- UITableView处理键盘遮挡
- 软键盘遮挡edittext处理
- 键盘遮挡屏幕解决方案
- [操作系统]处理UIScrollView中的编辑框被弹出键盘遮挡的问题
- (二)UITabBar and UINavigationController基础教程之UITextField键盘隐藏及防止键盘遮挡
- iOS第三方解决键盘遮挡-IQKeyboardManager
- iOS 提示信息被键盘遮挡解决方案
- IQKeyboardManager解决键盘遮挡问题
- Android输入框被键盘遮挡
- 【iOS 0 行代码系列】之 0 行代码解决键盘遮挡问题
- 完美解决EditText被软盘遮挡和键盘弹出布局不上移
- Android 输入法键盘和activity页面遮挡问题解决
- react-native 键盘遮挡view的解决办法
- iOS TextFiled、TextView 关于键盘的收起以及处理键盘遮挡
- ios键盘弹起不遮挡输入框
- ios关于键盘遮挡处理
- android 键盘弹出时将屏幕遮挡
- UITextField被弹出键盘遮挡
- 解决键盘遮挡输入框(UITextField)问题