如何在 iPhone 中调整 UINavigationController 的大小?

发布于 2024-09-01 01:15:25 字数 98 浏览 4 评论 0原文

我已经使用 UINavigationController 创建了一个应用程序,它看起来很好,现在我想将 NavigationController 的大小设置为较小的大小。我该怎么做?

I have created a application with UINavigationController and it is appearing fine now i want to make the size of the NavigationController to a smaller size. How can i do it?

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

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

发布评论

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

评论(3

清泪尽 2024-09-08 01:15:25

如果通过代码添加,则可以调整 UINavigatorController 的大小或移动...

    - (void)viewDidLoad
    {
            [super viewDidLoad];
            myview_view = [[[MyCustomView alloc] init]autorelease];
            ControlNav = [[UINavigationController alloc] initWithRootViewController:myview_view]; // Init the UINavigatorController
            ControlNav.navigationBarHidden = YES; // Hide the navigation bar
            ControlNav.view.frame = CGRectMake(50, 50, 665, 370);  // Move and resize the UINavigator Controller
            [self.view addSubview:ControlNav.view];  // Add subview
    }

MyCustomView 是一个 UIViewController;

You can resize or move the UINavigatorController if you add by code...

    - (void)viewDidLoad
    {
            [super viewDidLoad];
            myview_view = [[[MyCustomView alloc] init]autorelease];
            ControlNav = [[UINavigationController alloc] initWithRootViewController:myview_view]; // Init the UINavigatorController
            ControlNav.navigationBarHidden = YES; // Hide the navigation bar
            ControlNav.view.frame = CGRectMake(50, 50, 665, 370);  // Move and resize the UINavigator Controller
            [self.view addSubview:ControlNav.view];  // Add subview
    }

MyCustomView is an UIViewController;

似最初 2024-09-08 01:15:25

你不能。

根据 UINavigationController 文档,您必须更改外观的唯一选项是 barStyle半透明 属性;

除了少数例外,您应该
永远不要修改导航栏对象
直接地。是允许修改的
barStyle 或半透明属性
导航栏的但你必须
永远不要改变它的框架、边界或
直接阿尔法值。此外,
导航控制器对象
构建导航的内容
使用导航动态栏
项目(实例
UINavigationItem 类)关联
与视图控制器
导航堆栈。要改变
导航栏的内容,您
因此必须配置
自定义视图的导航项
控制器。欲了解更多信息
关于导航项,请参见
UINavigationItem 类参考。

You can't.

According to the UINavigationController documentation, the only options you have to change the look are the barStyle and the translucent properties;

With only a few exceptions, you should
never modify the navigation bar object
directly. It is permissible to modify
the barStyle or translucent properties
of the navigation bar but you must
never change its frame, bounds, or
alpha values directly. In addition,
the navigation controller object
builds the contents of the navigation
bar dynamically using the navigation
items (instances of the
UINavigationItem class) associated
with the view controllers on the
navigation stack. To change the
contents of the navigation bar, you
must therefore configure the
navigation items for your custom view
controllers. For more information
about navigation items, see
UINavigationItem Class Reference.

烟凡古楼 2024-09-08 01:15:25

重要提示:这个想法听起来不错,而且理论上似乎可行,但 iAd 框架不允许您将 AdBannerView 直接添加到 UIWindow。 <<<<<<<

您可以调整 UINavigationController 的大小,但无法移动顶部或底部工具栏。

下面是使 AdBanner 位于 UINavigationController 下方但底部工具栏上方的示例。此 AdBanner 将在您的视图中保持静止 - 它不会通过 UIViewController 的推送和弹出操作进行动画处理。

1) 在应用程序委托中调整 UINavigationController 的大小:

navigationController.view.frame = CGRectMake(0, 0, 320, 410);

2) 手动调整 ViewController 的大小以在下面添加间隙。执行此操作的一个好地方是在 viewDidLoad 方法中:

self.view.frame = CGRectMake(0, 0, 320, 322);

3) 将 AdBannerView 直接添加到应用程序的窗口(记住它只是另一个 UIView)。因此,AdBanner 将位于工具栏上方,但位于任何可见视图控制器下方。

[window addSubview:addBannerView];

它看起来像这样:

alt text

IMPORTANT: this idea sounded great in and seemed to work in theory, but the iAd framework doesn't allow you to add an AdBannerView directly to the UIWindow. <<<<<

You can resize a UINavigationController but you cannot move the top or bottom ToolBar.

Here is an example of making a AdBanner go below your UINavigationController but above it's bottom toolbar. This AdBanner will remain stationary in your view--it will not animated with UIViewController push and pop actions.

1) Resize your UINavigationController in the app delegate:

navigationController.view.frame = CGRectMake(0, 0, 320, 410);

2) Manually resize the ViewControllers to add a gap below. A good place to do this is in viewDidLoad method:

self.view.frame = CGRectMake(0, 0, 320, 322);

3) Add your AdBannerView directly to the application's window (remember it is just another UIView). So the AdBanner would go above the toolbar, but below any visible view controllers.

[window addSubview:addBannerView];

It looks something like this:

alt text

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