当 UINavigationBar 隐藏/显示时如何防止视图调整大小/转换

发布于 2024-09-02 20:07:14 字数 297 浏览 8 评论 0原文

我有一个带有选项卡栏和导航栏的应用程序。我推送一个用于显示照片的视图控制器,一次一张。它最初显示栏和前进/后退控制;延迟后,这些隐藏,使用标签栏上的 setNavigationBarHidden:animated: 和自定义转换 (CGAffineTransformMakeTranslation)。这是可行的,但是显示照片的视图控制器 view 会上下跳跃。如果我将选项卡栏排除在等式之外,情况也是如此。

如何防止 UINavigationBar 移动我的视图?我希望照片保持固定在屏幕上,导航栏下降到其顶部。

I have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.

How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

未央 2024-09-09 20:07:14

遇到这个问题并使用从 UINavigationController 继承的类修复了它,

-(void)viewWillAppear:(BOOL)animated
{
    self.navigationBar.translucent = YES;
}

对我来说效果很好,不必将样式设置为 UIBarStyleBlackTranslucent。所以它确实保留了我的颜色。

Had this issue and fixed it with a class that inherited from UINavigationController

-(void)viewWillAppear:(BOOL)animated
{
    self.navigationBar.translucent = YES;
}

Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.

执手闯天涯 2024-09-09 20:07:14
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];

这似乎对我有用!

[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];

this seemed to do the trick for me!

离去的眼神 2024-09-09 20:07:14

我知道这是一个老问题,但我通过在 Interface Builder

alt text中禁用“自动调整子视图大小”来实现这一点

I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder

alt text

沉默的熊 2024-09-09 20:07:14

除了将导航栏样式设置为半透明之外,我一直无法找到正确的方法来处理此问题,如下所示:

theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

除了创建另一个导航栏并向其添加按钮之外,这是最好的(这似乎是苹果所做的就在它的照片应用程序中)

I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:

theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文