我正在尝试将使用 .xib(不是情节提要)的 Single View 应用程序项目转换为UINavigationController
样式。我使用 Storyboard 了解它,这非常简单。但是,我想在没有情节提要的情况下实现。在我创建了一个单视图应用程序项目后,它UIView
默认带有一个 ViewController_XXX.xib。之后,我如何使用它创建根视图控制器并制作UINavigationController
样式。有没有教程的地方?
问问题
233 次
2 回答
1
来自此链接的参考
- (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;
}
于 2012-09-27T08:13:03.777 回答
1
- 在中创建一个 NavigationController
AppDelegate.h
@property(强,非原子) UINavigationController *navigationController;
- 编辑 AppDelegate.m
-(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; }
于 2012-09-27T08:20:01.663 回答