gpt4 book ai didi

ios - 使用 UINavigationController 弹出到上一个 View Controller 时屏幕下方有线黑色空间

转载 作者:行者123 更新时间:2023-11-29 13:11:00 25 4
gpt4 key购买 nike

我正在使用 UINavigationController 来引导一些 View controllers。在一些 View Controller 中,我不想使用 UINavigationBar,但是在我可能会使用其他一些。现在,我尝试使用 UINavigationBar 将一个 View Controller 弹出到其前一个隐藏 UINavigationBar 的 View Controller 。但是当弹出时,屏幕下方有一个有线的黑色空间。旋转屏幕后,空间将消失。

普通的 View Controller A应该是这样的:

enter image description here

当按下文本按钮时,会推送一个 View Controller B,如下所示: enter image description here

当点击导航栏上的后退按钮时。 A会出来,但底部有一个黑色空间。

enter image description here

如果旋转屏幕,空格就会消失。在 A 的 - (void)viewWillAppear:(BOOL)animated 方法中,我隐藏了导航栏并让屏幕自动旋转。

- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
[self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}

这种情况有什么问题吗?任何帮助将不胜感激。

最佳答案

我在后退按钮操作方法中添加了 setNavigationBarHidden: 方法。有用。如果我在 viewWillDisappear: 方法或其他方法中添加此方法,它似乎不起作用。导航栏将影响下一个出现的 View Controller 。这意味着,导航堆栈中的下一个 View Controller 中将有一个黑色空间。

最后,我为后退按钮添加了一个action方法,方法中添加了setNavigationBarHidden:YES,如下:

- (void)backBtnClicked:(id)sender
{
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController setNavigationBarHidden:YES];
}

关于ios - 使用 UINavigationController 弹出到上一个 View Controller 时屏幕下方有线黑色空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17376868/

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