2016-11-23 1 views
0

일부 도시를 나열하는 UITableViewController (A)가 있습니다. 사용자가 행을 탭하면 UIPageViewController (B)로 이동하여 폼의 UIViewController (X)에 여러 페이지를 전달하여 해당 도시의 세부 정보를 표시합니다. 인구, 역사 .... 그래서 사용자가 도시를 컨설팅 할 때 그는 가로로 스 와이프하여 이전 도시와 다음 도시를 참조 할 수 있습니다. 이보기 (X)에는 "지도 표시"버튼이 있습니다. 사용자가이 버튼을 누르면 UIViewController (C)로 이동하여 목록 "A"에있는 모든 도시의 핀을 포함하는 MKMapView를 표시합니다. 그래서 사용자가 보스턴시와 상담하고 있다면 "지도 표시"버튼을 클릭하고지도를 모든 도시와 함께 본 다음 뉴욕 핀을 두드리고 B보기로 되돌립니다 X) API와 함께3 개의 교차보기 컨트롤러를 통해 이동하는 방법

// viewControllers: A,B,C; we go from C to B 
[previousControllerB SetCity:NewYorkCityID]; 
[self.navigationController popViewControllerAnimated:YES]; 

간단한. 그리고 그것은 잘 작동합니다.

UITableViewController A (목록)에서 "지도 표시"버튼도 배치 했으므로 사용자는 컨트롤러 B를 거치지 않고 모든 도시 핀을 표시하는지도를 참조 할 수 있습니다. 지도에서 사용자가 "New York"핀을 클릭하면 UIPageViewController B 내에 View X를 표시해야합니다. 따라서 사용자는 여전히 스 와이프하여 도시로 돌아갈 수 있습니다. 여기에 문제가 있습니다.

다시보기 컨트롤러 A (목록)로 이동 한 다음보기 B (양식)를 누르면 잘못된 애니메이션이 표시됩니다. 나는 controllerA를보고 싶지 않아.

// viewControllers: A,C; we go from C to A then to B thanks to the segue GoToControllerB 
[self.navigationController popToViewController:controllerA animated:YES]; // even animated:NO gives bad results 
[controllerA performSegueWithIdentifier:@"GoToControllerB" sender:NewYorkCityID]; 

새로운 viewController B를 인스턴스화하고 밀어 넣으면 작동하지 않습니다. 전환율이 50 %로 차단되면 검정색 반쪽 스크린 (오른쪽)이 표시되고 아무런 변화가 없습니다.

// viewControllers: A,C; we instantiate B then we go from C to B 
ViewControllerB *controllerB = [self.storyboard instantiateViewControllerWithIdentifier:@"ControllerB"]; 
controllerB.view = controllerB.view; 
[controllerB SetCity:NewYorkCityID]; 
[self.navigationController pushViewController:controllerB animated:YES]; 

은 내가 인스턴스화하고 UIPageViewController 밀어 경우에만이 문제가 발생하는 것으로 나타났습니다, 나는 인스턴스화하고 UIViewControllers를 밀어 경우는 절대 발생하지 않습니다. 첫 번째 질문은 UIPageViewController를 인스턴스화하고 푸시하는 방법입니다.

그런데 최근의 경우 컨트롤러 C에서 뷰 B를 인스턴스화했기 때문에 잘못된 컨트롤러 시퀀스 (A, C, B)가 나타납니다. 오른쪽 순서는 항상

A,B,C (so: list, form, map) 
or 
A,C (so: list, map) 
    in this case, if the user from C (map), clicks on a city-pin and goes to B (form), the back button here must always bring him from B to A (the list) and not to the Map (C). 

그래서 나는 다음과 같은 생각해야한다 : 사용자가지도에 도시 핀를 클릭하면, 첫째로 나는의 ViewController B의 인스턴스를 (그래서 순서가 지금 A, C, B) 그런 다음 self.navigationController.viewController에서 컨트롤러 C를 제거합니다. 그래서 사용자가 B에 있고 뒤로 버튼을 누르면 그는 항상 A 컨트롤러로갑니다. 이 작업을 수행 할 수 있습니까? 그렇게하는 방법? 모든 샘플 코드? 고맙습니다.

답변

0

... 탐색 순서를이 시도에 대한 유지 보수 A -> B -> C

1. go to ViewController C 

    ViewControllerc *objvcC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerC"]; 
    [self.navigationController pushViewController:objvcC animated:YES]; 



2. then add ViewController to existing navigation stack 


    ViewControllerB *objViewControllerB = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerB"]; 
    NSMutableArray *existNavigationArray = [self.navigationController.viewControllers mutableCopy]; 
    [existNavigationArray insertObject:objViewControllerB atIndex:existNavigationArray.count -1]; 
    self.navigationController.viewControllers = existNavigationArray; 
관련 문제