OC--初始化UINavigationController

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

  // create a navigation controller and perform some simple styling

  self.navigationController = [UINavigationController new];

  self.navigationController.navigationBar.barTintColor = [UIColor darkGrayColor];

  [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

  

  // create and navigate to a view controller

  UIViewController *viewController = [self createInitialViewController];

  [self.navigationController pushViewController:viewController animated:NO];

 

  // show the navigation controller

  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

  self.window.rootViewController = self.navigationController;

  [self.window makeKeyAndVisible];

  return YES;

}

 

- (UIViewController *)createInitialViewController {

  self.viewModelServices = [[RWTViewModelServicesImpl alloc] initWithNavigationController:self.navigationController];

  self.viewModel = [[RWTFlickrSearchViewModel alloc]

                    initWithServices:self.viewModelServices];

  return [[RWTFlickrSearchViewController alloc]

          initWithViewModel:self.viewModel];

}

posted on 2015-10-15 13:48  大木哥  阅读(461)  评论(0编辑  收藏  举报

导航