2011-04-05 3 views
3

Navigation Controller를 사용하고 있습니다. 내 RootViewController는 여러 뷰를 푸시하지만 모달 뷰를 제공합니다. 모달 뷰는 tableView를 제공합니다. 그래서 내가하려는 것은 모달 뷰에서 네비게이션 컨트롤러를 밀고 그 모달 뷰에서 그것을 사용하여 뷰를 tableView로 푸시 할 수 있다는 것입니다. 또는 모달 뷰에서 두 번째 Navigation Controller를 구현할 수있는 방법이 있습니까?Modal View의 NavigationController?

실제 문제는 오른쪽에서 왼쪽으로의 전환을 사용하여 tableView에서 뷰를 표시하려는 것입니다. 물론 이것은 모달 뷰에서 사용할 수 없습니다.

나는 종류의 탐색 컨트롤러에 의해 사용되는 왼쪽의 전환에 대한 권리를 제공하는이 코드를 가지고 :

NewViewController *newViewController = [[NewViewController alloc] init]; 
[self presentModalViewController:newViewController animated:NO]; 

CGSize theSize = CGSizeMake(320, 460); 
newViewController.view.frame = CGRectMake(0 + theSize.width, 0 + 20, theSize.width, theSize.height); 
[UIView beginAnimations:@"animationID" context:NULL]; 
[UIView setAnimationDuration:0.5]; 
newViewController.view.frame = CGRectMake(0, 0 + 20, 320, 460); 
[UIView commitAnimations]; 
[newViewController release]; 

문제는 NewViewController가 건너 전환하도록 OldViewController합니다 (NewViewController를 호출 한) 즉시 사라입니다 OldViewController를 덮는 대신 빈 화면이 표시됩니다.

+0

'presentModal ... animated : false'를 사용하여 'UIView animations'을 할 수 있습니다. 'presentmodal ... '애니메이션을 무시할만한 이유가 있을까요? –

+1

네비게이션 컨트롤러에서만 가능했던 오른쪽에서 왼쪽으로 애니메이션을 전환하려고합니다. –

+0

여기에 무엇이 요청되는지 알기가 어렵습니다. 이 질문은 애매 모호하고 불완전하며 ... –

답변

10

UIViewController를 표시하면 완전히 새로운 탐색 스택이 모달로 만들어집니다.

//Create the view you want to present modally 
UIViewController *modalView = [[UIViewController alloc] init]; 
//Create a new navigation stack and use it as the new RootViewController for it 
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:modalView]; 
//Present the new navigation stack modally 
[self presentModalViewController:nav animated:YES]; 
//Release 
[modalView release]; 
[nav release]; 

이것은 UINavigationController가 UIViewController의 하위 클래스이기 때문에 수행 할 수 있습니다. 새보기가로드되면 원하는대로 사용할 수 있습니다 (다른보기를 그 위에 올려 놓으면 Waqas suggeste 등의 UIView 애니메이션이 표시됩니다).

나는 당신의 질문을 올바르게 받았기를 바랍니다. 내가하지 않았 으면 말해봐.

+0

고마워. 내가 지금 가지고있는 것은 이것이다 : [RootViewController1] -> [ModalViewController2] -> [Modal Transition을 가진 ViewController3] 선물. 지금 내가 갖고 싶은 것은 [RootViewController1] -> [ModalViewController2] -> [Navigation Controller Transition이있는 Push 된 ViewController3]입니다. 그 방법은 당신이 철자 한 방법을 사용합니까? –

+0

트릭을해야합니다. 생각해 보니, 여기에 쉬운 해결책이 있다고 믿습니다. 첫 번째 뷰를 모달로 표시 한 다음 viewDidAppear 메서드에서 테이블 뷰를 밀어 넣을 수 있습니다. – nadavhart

+0

또한 중간보기로 인해 지연이있는 경우 Animated : NO로 모달로 시도하여 푸시 할 수 있습니다. – nadavhart