我现在正在学习IOS progrmaming,并且不知道如何从我的两个当前视图控制器设置选项卡式视图控制器。有人可以帮忙吗如果您需要更多信息,请与我们联系。我只想为这些UINAvigationControllers中的每一个选择一个选项卡。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/*
This is how you set up with movies at root
*/
NSString *moviesURLString = @"irrelevantURL";
self.movieDataSource = [[MoviesDataSource alloc] initWithMoviesAtURLString:moviesURLString];
MoviesTableViewController *mvc = [[MoviesTableViewController alloc] init];
UINavigationController *mnc = [[UINavigationController alloc] initWithRootViewController:mvc];
// [self.window setRootViewController:mnc];
/*
This is how you set up with theaters at root
*/
NSString *theatersURLString = @"irrelevantURL";
self.movieTheaterDataSource = [[MovieTheaterDataSource alloc] initWithMovieTheatersAtURLString:theatersURLString];
MovieTheaterTableViewController *mtvc = [[MovieTheaterTableViewController alloc] init];
UINavigationController *mtnc = [[UINavigationController alloc] initWithRootViewController:mtvc];
// [self.window setRootViewController:mtnc];
/*
Trying to set up tabbed views
*/
UITabBar *tabbedView = [[UITabBar alloc] init];
return YES;
}
答案 0 :(得分:0)
您需要做的事情如下 *制作UIWindow类实例 *创建UITabBarController类实例并将两个UINavigationControllers分配给UITabBarController实例viewControllers属性。
因此,您应该编写的代码如下所示。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
/*
This is how you set up with movies at root
*/
NSString *moviesURLString = @"irrelevantURL";
self.movieDataSource = [[MoviesDataSource alloc] initWithMoviesAtURLString:moviesURLString];
MoviesTableViewController *mvc = [[MoviesTableViewController alloc] init];
UINavigationController *mnc = [[UINavigationController alloc] initWithRootViewController:mvc];
/*
This is how you set up with theaters at root
*/
NSString *theatersURLString = @"irrelevantURL";
self.movieTheaterDataSource = [[MovieTheaterDataSource alloc] initWithMovieTheatersAtURLString:theatersURLString];
MovieTheaterTableViewController *mtvc = [[MovieTheaterTableViewController alloc] init];
UINavigationController *mtnc = [[UINavigationController alloc] initWithRootViewController:mtvc];
//set up tabBarController
UITabBarController *tabvc = [[UITabBarController alloc] init];
tabvc.viewControllers = @[mnc, mtnc];
self.window.rootViewController = tabvc;
[self.window makeKeyAndVisible];
return YES;
}
答案 1 :(得分:0)
你有没有在main.storyboard中设置它?
如果你这样做,你不需要使用app delegate。