2014-10-18 1 views
0

현재 IOS 프로 그램을 배우고 있고 현재 두 개의 현재 뷰 컨트롤러에서 탭형 뷰 컨트롤러를 설정하는 방법을 모른다. 누군가 도와 줄 수 있어요. 더 많은 정보가 필요하면 알려주세요. 이 UINAvigationController 각각에 대해 하나씩 두 개의 탭만 있으면됩니다.앱 뷰어에서 탭형 뷰 컨트롤러를 사용하도록 수정

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

다음과 같이하십시오.
* UIWindow 클래스 인스턴스를 만듭니다.
* UITabBarController 클래스 인스턴스를 만들고 UITabBarController 인스턴스 viewControllers 속성에 두 개의 UINavigationController를 할당합니다.

그래서 작성해야하는 코드는 다음과 같습니다.

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

그러나 tabvc.viewControllers = [NSArray arrayWithObjects : mnc, mtnc, nil];과 같이 tabvc를 초기화해야했는데이를 변경하거나 'tabvc.viewControllers = [mnc, mtnc]; "Expected Identifier"오류가 있습니다. 잘못 표시했습니다. – preezzzy

+0

죄송합니다. 해당 배열을 입력합니다. –

0

main.storyboard에 설정 했습니까?

당신은 애플 리케이션 대리인을 사용해야하지 않아도됩니다.

+0

안녕하세요, 저는 스토리 보드를 사용해 주셔서 감사합니다. – preezzzy