简短的回答是:是的。
UINavigationController的设计目的是在屏幕上或屏幕外管理和动画一堆视图控制器(与其他一些界面元素(如导航栏或工具栏)结合使用)。传统上,UINavigationControllers被App Delegate强力拥有并初始化,因为它们被认为是最重要的根对象。呈现出UINavigationController
的正确使用的示例类可能是这样的:
#import <UIKit/UIKit.h>
@interface CFIExampleAppDelegate : NSResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) UINavigationController *navigationController;
@end
@implementation CFIExampleAppDelegate
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:UIScreen.mainScreen.bounds];
self.navigationController = [[UINavigationController alloc]initWithRootViewController:/*Some Controller Instance*/];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
@end
长的答案,一如既往,是
号
的UINavigationController可以平凡重新实现(和它有很多次)效果很好。就像UIViewController的子类一样简单,并且在某种堆栈上(如NSMutableArray)一样。
要推送viewController YES,您需要将该消息发送给UINavigationController;如果你需要推送viewControllers,你需要一个基于导航的应用程序,它有一个UINavigationController,你可以添加你想要的任何东西(一个viewController作为navController,UITableView或任何其他视图的根) –