繁体   English   中英

在显示键盘时不使用滚动视图(iOS)的情况下上下调整视图的最佳做法是什么?

[英]What is a good practice to adjust/moving view up and down when keyboard is shown, without using a scroll view(iOS)?

在显示键盘时不使用滚动视图的情况下上下调整/移动视图的一种好的做法/方法是什么?

我发布此消息是因为我的方法无法正常工作,并且我非常需要一种安全且有效的方法。

您是否尝试过如下所示?

- (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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM