iPhone:移动UINavigationBar? [英] iPhone: Move UINavigationBar down?

查看:100
本文介绍了iPhone:移动UINavigationBar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将导航栏放在屏幕顶部下方。

I'm trying to position the navigation bar below the top of the screen.

我在 viewWillAppear中尝试了以下内容

self.navigationController.view.frame = CGRectMake(0.0, 54.0, 320.0, 426.0);
self.navigationController.navigationBar.frame = CGRectMake(0.0, 0.0, 320.0, 44.0);

问题是它似乎只在第一次显示视图时起作用。如果您转到另一个选项卡,然后返回,则导航栏位于屏幕顶部。当iPhone旋转时也会发生这种情况。

The problem is it only seems to work the very first time the view is displayed. If you go to another tab, and back, the navigation bar is at the top of the screen. This also happens when the iPhone is rotated.

我应该尝试调整导航控制器框架,还是应该尝试将导航控制器添加到另一个视图中在屏幕顶部下方?

Should I be trying to adjust the navigation controller frame, or should I instead try to add the navigation controller to another view that is below the top of the screen?

推荐答案

虽然很晚,我希望这仍然可以帮助其他人。我在viewDidAppear中使用了Stephens代码:动画,导航栏在返回选项卡时保持不变。这允许我在导航栏上方使用徽标。我在viewController中使用了这个。

Although late, I hope this can still help someone else out. I used Stephens code inside viewDidAppear:animated and the navigation bar stays put upon traveling back to the tab. This allowed me to use a logo above the navigation bar. I used this inside my viewController.

    - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.navigationController.view.frame = CGRectMake(0.0, 100.0, 320.0, 426.0); 
self.navigationController.navigationBar.frame = CGRectMake(0.0, 0.0, 320.0, 44.0); 
[self loadData];
    }

这篇关于iPhone:移动UINavigationBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆