在不使用滚动视图的情况下,在显示键盘时上下调整/移动视图的好方法/方法是什么?
我发布了this,因为我的方法工作不正常,我迫切需要一种安全且有效的方法。
答案 0 :(得分:0)
您是否尝试过如下?
- (void)viewDidLoad
{
NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(keyboardDidAppear) name:UIKeyboardDidShowNotification object:nil];
[center addObserver:self selector:@selector(keyboardWillDisAppear) name:UIKeyboardWillHideNotification object:nil];
}
-(void)keyboardDidAppear
{
CGRect frame = view.frame;
frame.origin.y -= 214.0;
view.frame = frame;
}
-(void)keyboardWillDisAppear
{
CGRect frame = view.frame;
frame.origin.y += 214.0;
view.frame = frame;
}