使用情节提要时如何继承导航控制器?

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

本文介绍了使用情节提要时如何继承导航控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 Xcode 菜单编辑器...嵌入...导航控制器"在界面构建器中使用情节提要.

I'm using storyboards in interface builder using the Xcode menu 'Editor...Embed in...Navigation Controller'.

似乎在 iOS 6 中,您必须将 UINavigationController 子类化以允许所有方向,使用

It seems that in iOS 6 you have to subclass the UINavigationController to allow all orientations, with

- (NSUInteger)supportedInterfaceOrientations {
    return (UIInterfaceOrientationMaskAll   );
}

但是由于代码中没有对 UINavigationController 的引用,如何将 UINavigationController 子类化为情节提要应用程序?

But how do I subclass the UINavigationController with a storyboard app as there is no reference to it in the code?

推荐答案

可以从storyboard中选择导航控制器场景的导航控制器:

You can select the navigation controller scene's navigation controller from the storyboard:

然后使用右侧的身份检查器更改类:

And then use the identity inspector on the right to change the class:

例如,将类"更改为 MyCustomNavigationController,然后在您的项目中创建一个名为 MyCustomNavigationController 的新类:

For instance change the "Class" there to MyCustomNavigationController and then just create a new class in your project called MyCustomNavigationController:

MyCustomNavigationController.h:

#import <UIKit/UIKit.h>

@interface MyCustomNavigationController : UINavigationController
@end

MyCustomNavigationController.m:

@implementation MyCustomNavigationController

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

... any other methods you want ...

@end

这篇关于使用情节提要时如何继承导航控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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