#import "LYViewController.h"
@interface LYViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomSpace;
@end
@implementation LYViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"评论";
self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:@"commend_detail_top_forward_normal.9" highLightedImage:@"commend_detail_top_forward_pressed.9" target:self action:@selector(btnClick:)];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
- (void)btnClick:(UIButton *)btn {
}
- (void)keyboardWillChangeFrame:(NSNotification *)note {
// 键盘显示或者隐藏完毕的frame
CGRect frame = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
// 修改底部约束
self.bottomSpace.constant = KScreenHeight - frame.origin.y;
// 动画时间
CGFloat duration = [note.userInfo[UIKeyboardAnimationCurveUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{
[self.view layoutIfNeeded];
}];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
textField随键盘上下移动
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 原文链接http://www.cnblogs.com/kenshincui/p/4186022.html 音频在i...