0

我正在尝试将使用 .xib(不是情节提要)的 Single View 应用程序项目转换为UINavigationController样式。我使用 Storyboard 了解它,这非常简单。但是,我想在没有情节提要的情况下实现。在我创建了一个单视图应用程序项目后,它UIView默认带有一个 ViewController_XXX.xib。之后,我如何使用它创建根视图控制器并制作UINavigationController样式。有没有教程的地方?

4

2 回答 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
  1. 在中创建一个 NavigationControllerAppDelegate.h

@property(强,非原子) UINavigationController *navigationController;

  1. 编辑 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 回答