RootViewController, DataViewController 및 ModelController를 만드는 xcode의 페이지 기반 응용 프로그램 템플릿을 사용하고 있습니다.DataViewController에서 UIPageViewController 페이지로 이동 하시겠습니까?
내가 RootViewController에서 필요한 페이지로 이동하도록 만들었지 만 특정 페이지의 이벤트에 대해 트리거 된 DataViewController에서도 필요합니다. 그렇게 잘 작동하지 않습니다. DataViewController에서 작동하도록 코드를 어떻게 변경해야합니까?
내 코드는 다음과 같습니다 -from 루트 (작업) :
//get current index of current page
DataViewController *theCurrentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSUInteger retreivedIndex = [self.modelController indexOfViewController:theCurrentViewController];
//get the page(s) to go to
DataViewController *targetPageViewController = [self.modelController viewControllerAtIndex:(pageToGoTo - 1) storyboard:self.storyboard];
//put it(or them if in landscape view) in an array
NSArray *theViewControllers = nil;
theViewControllers = [NSArray arrayWithObjects:targetPageViewController, nil];
//check which direction to animate page turn then turn page accordingly
if (retreivedIndex < (pageToGoTo - 1) && retreivedIndex != (pageToGoTo - 1)){
[self.pageViewController setViewControllers:theViewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
}
if (retreivedIndex > (pageToGoTo - 1) && retreivedIndex != (pageToGoTo - 1)){
[self.pageViewController setViewControllers:theViewControllers direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL];
}
-from 페이지, dataviewcontroller (작동하지 않는) :
DataViewController *targetPageViewController = [((UIPageViewController*)self.parentViewController) viewControllerAtIndex:(pageToGoTo - 1) storyboard:self.storyboard]; //The problem is here, but I do not know how to solve it.
//put it(or them if in landscape view) in an array
NSArray *theViewControllers = nil;
theViewControllers = [NSArray arrayWithObjects:targetPageViewController, nil];
[((UIPageViewController*)self.parentViewController) setViewControllers: theViewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
감사합니다. 대리인을 사용했습니다. 그것이 그 당시에 무엇인지 알지 못했습니다. 나는이 해결책이 또한 작동 할 수 있었다는 것을 짐작한다. –