SingleViewApplication项目中的UINavigationController样式

时间:2012-09-27 08:11:21

标签: iphone uinavigationcontroller

我正在尝试将使用.xib(非故事板)的单一视图应用程序项目转换为UINavigationController样式。我使用Storyboard知道它很容易。但是,我想在没有故事板的情况下实施。创建单视图应用程序项目后,它默认在ViewController_XXX.xib中带有UIView。之后,我如何使用它创建根视图控制器并制作UINavigationController样式。在某处有任何教程吗?

2 个答案:

答案 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)

  1. AppDelegate.h
  2. 中创建一个NavigationController
      

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

    1. 编辑AppDelegate.m
    2.   

      - (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;
       }