iOS相应键盘高度变化,相应控件随之变化的代码段
2013-03-29 15:14
357 查看
//注册通知
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
//响应通知
#pragma mark keyboard notification
- (void)keyboardWillShow:(NSNotification *) notification {
float animationDuration = [[[notification
userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]
floatValue];
CGFloat height = [[[notification
userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]
CGRectValue].size.height;
CGRect bottomBarFrame =
self.mToolBar.frame;
{
[UIView
beginAnimations:@"bottomBarUp"
context:nil];
[UIView setAnimationDuration: animationDuration];
[UIView
setAnimationCurve:UIViewAnimationCurveEaseInOut];
bottomBarFrame.origin.y =
self.view.bounds.size.height -
44 - height;
self.mToolBar.frame = bottomBarFrame;
[UIView
commitAnimations];
}
}
- (void)keyboardWillHide:(NSNotification *) notification {
float animationDuration = [[[notification
userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]
floatValue];
CGFloat height = [[[notification
userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]
CGRectValue].size.height;
CGRect bottomBarFrame =
self.mToolBar.frame;
if (bottomBarFrame.origin.y <
300)
{
[UIView
beginAnimations:@"bottomBarDown"
context:nil];
[UIView setAnimationDuration: animationDuration];
[UIView
setAnimationCurve:UIViewAnimationCurveEaseInOut];
bottomBarFrame.origin.y += height;
self.mToolBar.frame = bottomBarFrame;
[UIView
commitAnimations];
}
}
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
//响应通知
#pragma mark keyboard notification
- (void)keyboardWillShow:(NSNotification *) notification {
float animationDuration = [[[notification
userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]
floatValue];
CGFloat height = [[[notification
userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]
CGRectValue].size.height;
CGRect bottomBarFrame =
self.mToolBar.frame;
{
[UIView
beginAnimations:@"bottomBarUp"
context:nil];
[UIView setAnimationDuration: animationDuration];
[UIView
setAnimationCurve:UIViewAnimationCurveEaseInOut];
bottomBarFrame.origin.y =
self.view.bounds.size.height -
44 - height;
self.mToolBar.frame = bottomBarFrame;
[UIView
commitAnimations];
}
}
- (void)keyboardWillHide:(NSNotification *) notification {
float animationDuration = [[[notification
userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]
floatValue];
CGFloat height = [[[notification
userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]
CGRectValue].size.height;
CGRect bottomBarFrame =
self.mToolBar.frame;
if (bottomBarFrame.origin.y <
300)
{
[UIView
beginAnimations:@"bottomBarDown"
context:nil];
[UIView setAnimationDuration: animationDuration];
[UIView
setAnimationCurve:UIViewAnimationCurveEaseInOut];
bottomBarFrame.origin.y += height;
self.mToolBar.frame = bottomBarFrame;
[UIView
commitAnimations];
}
}
相关文章推荐
- 【代码笔记】iOS-屏幕根据键盘自动的变化高度
- 【代码笔记】iOS-屏幕根据键盘自动的变化高度
- 完美适应iOS中的键盘高度变化
- iOS开发之监听键盘高度的变化
- iOS开发中的键盘高度变化处理
- iOS开发中的键盘高度变化处理
- IOS自定义View实现相应的控件点击方法以及代理的总结(附代码)
- iOS开发之监听键盘高度的变化
- 适应iOS中的键盘高度变化
- 完美适应iOS中的键盘高度变化
- iOS 中键盘上工具栏高度的变化
- iOS屏幕根据键盘自动变化高度
- 完美适应iOS中的键盘高度变化
- iOS开发中的键盘高度变化处理
- 如何完美适应iOS中的键盘高度变化
- iOS开发之监听键盘高度的变化 分类: ios技术 2015-04-21 12:04 233人阅读 评论(0) 收藏
- iOS开发中的键盘高度变化处理
- XMPP框架 微信项目开发之Socket聊天室发送数据——获取键盘高度,修改控件的约束值,代码滚动UITabView到指定位置
- [ios] 适应键盘高度变化
- [ios] 适应键盘高度变化