我正在尝试将使用.xib(非故事板)的单一视图应用程序项目转换为UINavigationController
样式。我使用Storyboard知道它很容易。但是,我想在没有故事板的情况下实施。创建单视图应用程序项目后,它默认在ViewController_XXX.xib中带有UIView
。之后,我如何使用它创建根视图控制器并制作UINavigationController
样式。在某处有任何教程吗?
答案 0 :(得分:1)
此LINK
的参考资料- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UINavigationController* navigationController =[[UINavigationController alloc] init];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[navigationController pushViewController:self.viewController animated:NO];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
答案 1 :(得分:1)
AppDelegate.h
@property(强大,非原子)UINavigationController * navigationController;
- (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIViewController *rootController = [[YourViewController alloc] initWithNibName:@"nibfile name" bundle:nil]; navigationController = [[UINavigationController alloc] initWithRootViewController:rootController]; [navigationController.navigationBar setTintColor:[UIColor colorWithHue:5.84 saturation:0.05 brightness:0.02 alpha:0.0]]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window addSubview:navigationController.view]; [self.window makeKeyAndVisible]; return YES; }