iPhone:向下移动 UINavigationBar?

2023-06-12移动开发问题
4

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

问题描述

我正在尝试将导航栏定位在屏幕顶部下方.

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

我在 viewWillAppear 中尝试了以下方法:

I've tried the following in 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:animated 中使用了 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7