2011-03-10 2 views
2

하나의 탭 막대 항목에 2 개의 탐색 컨트롤러를 연결하고 싶습니다.두 개의 탐색 컨트롤러를 하나의 탭 막대에 추가하십시오.

기본적으로 단일 탭 항목에 2 개의보기가 있고 화면을 밀고 팝하는 탐색 모음이 있어야합니다. (iPad의 설정 응용 프로그램과 동일).

편집 ======

자신의 네비게이션 컨트롤러와 다른보기가 자신의 네비게이션 컨트롤러와 오른쪽에보기 (또는 다른이 그것은 왼쪽에있는 모양을

UI) 푸시 팝 물건을 얻을 수 있습니다.

하나의 탭 표시 줄 항목에 탐색 컨트롤러를 연결하는 방법을 알고 있습니다.

ModalView 발행일 : - conmulligan 코드를 구현하여 모든 것이 작동합니다. 하지만 lansdscape 모드에서 일부 ModalViewController를 표시하려고하면이 ModalView를 닫으려고하면 FirstViewController 탐색 표시 줄이 세로로 (보기와 함께) 표시되고 SecondViewController NavigationBar가 가로로 유지됩니다. 이것은 시뮬레이터에없는 장치에서만 발생합니다.

아래는 내 ModalViewController 코드입니다. ModalViewCntroller을 Dismising를 들어

ModalTableViewController *modalTableViewController = [[ModalTableViewController alloc]initWithNibName:@"ModalTableViewController" bundle:[NSBundle mainBundle]]; 
UINavigationController *localNavigationViewController = [[UINavigationController alloc] initWithRootViewController:modalTableViewController]; 
localNavigationViewController.modalPresentationStyle = UIModalPresentationFormSheet; 
[self presentModalViewController:localNavigationViewController animated:YES]; 
[modalTableViewController release]; 
[localNavigationViewController release]; 

나는 다음과 같이 그것을 : -

[self dismissModalViewControllerAnimated:YES]; 

당신의 응답을 기다리는 중. enter image description here

답변

4

두 가지 탐색 컨트롤러가 포함 된 UIViewController 하위 클래스를 만들고이를 UITabBarController에 추가하는 것이 한 가지 방법입니다. 이것은

FirstViewController *firstViewController = [[FirstViewController alloc] init]; 
UINavigationController *firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController]; 
[firstViewController release]; 

SecondViewController *secondViewController = [[SecondViewController alloc] init]; 
UINavigationController *secondNavigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController]; 
[secondViewController release]; 

firstNavigationController.view.frame = CGRectMake(0.f, 0.f, 320.f, self.view.frame.size.height); 
firstNavigationController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight; 

secondNavigationController.view.frame = CGRectMake(321.f, 0.f, self.view.frame.size.width - 321.f, self.view.frame.size.height); 
secondNavigationController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | 
                UIViewAutoresizingFlexibleRightMargin; 

[self.view addSubview:firstNavigationController.view]; 
[self.view addSubview:secondNavigationController.view]; 

더 많거나 적은 방법 후드 아래 UISplitViewController 작품 : 다음은 UIViewController-viewDidLoad 방법 탐색 컨트롤러를 만들고 레이아웃 줄 방법입니다.

편집 : 당신이 그것을 제대로 레이아웃 확인하기 위해 다음 코드를 추가 할 필요가 있습니다

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [firstNavigationController viewWillAppear:animated]; 
    [secondNavigationController viewWillAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated { 
    [super viewWillDisappear:animated]; 
    [firstNavigationController viewWillDisappear:animated]; 
    [secondNavigationController viewWillDisappear:animated]; 
} 

- (void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    [firstNavigationController viewDidAppear:animated]; 
    [secondNavigationController viewDidAppear:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated { 
    [super viewDidDisappear:animated]; 
    [firstNavigationController viewDidDisappear:animated]; 
    [secondNavigationController viewDidDisappear:animated]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return YES; 
} 
+0

- 답장을 보내 주셔서 감사합니다. 가로 모드에서 앱을 시작하려고하면 내보기에서 두보기를 모두 볼 수 없습니다. secondViewController라는보기 하나만 볼 수 있습니다. 이 일을 도와 줄 수 있어요? – Ekra

+0

안녕하세요 @ 에크라, 그게 이상 해요, 그것은 나를 위해 작동합니다. 위의 추가 코드를 'UIViewController' 서브 클래스에 추가하십시오. – conmulligan

+0

- 답장을 보내 주셔서 감사합니다. 위에서 설명한 ModalView를 표시하는 데 문제가 있습니다. 그것 좀 봐주세요. 당신의 응답을 기다리는. – Ekra

관련 문제