gpt4 book ai didi

ios - 状态栏隐藏后 View 被推下?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:33:21 25 4
gpt4 key购买 nike

我有一个没有状态栏的 UIViewController,它会启动第二个有状态栏的 UIViewController

如果扩展状态栏处于事件状态,两个 View 都可以正确显示,但是当我退出第二个 View 并返回到第一个 View 时,我会在顶部看到一个 20pt 的黑条,整个 View 被向下推,遮住底部.

我尝试在 viewDidAppear 中将框架重置为原点 0,0,但没有任何效果。

为什么 View 被下推,我该如何解决?

- (BOOL)prefersStatusBarHidden {
return YES;
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.view.frame = CGRectMake(0, 0, self.width, self.height);
self.view.backgroundColor = [UIColor redColor];
}

- (void)openShare {
Share *share = [[Share alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:share];

nav.modalTransitionStyle = UIModalPresentationPopover;
[self presentViewController:nav animated:YES completion:nil];
}

调用 openShare 之前的 View 顶部:

enter image description here

呈现和关闭 Share 后的 View 顶部:

enter image description here

最佳答案

昨天我在我的应用程序中遇到了完全相同的问题。

我做了两件事来解决这个问题。

  1. 我将导航栏上的 Top Space to: Top Layout Guide 约束条件设置为 20(与状态栏高度相同)
    Constaint
  2. 我在有问题的 Controller 中添加了这个 ([self.view layoutSubviews])

    -(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    [self.view layoutSubviews];
    }

关于ios - 状态栏隐藏后 View 被推下?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37197965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com