Tôi có UIViewController chứa các ViewControllers khác. Ban đầu ViewController được thiết lập trong viewDidLoad:Xoay của UIPageViewController trong Bộ điều khiển Xem Vùng chứa
FirstViewController *first = [FirstViewController alloc] init];
first.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
first.view.frame = m_content.frame;
[self addChildViewController:first];
[m_content.view addSubview:first.view];
[first didMoveToParentViewController:self];
m_activeViewController = first;
này điều khiển container đã thực hiện automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers trở YES. Nó cũng đã thực hiện để manualy thay đổi luân chuyển về phía trước để ViewControllers không hoạt động
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
for(UIViewController *vc in m_viewControllers)
{
if(vc != [m_activeViewController]
[vc willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
for(UIViewController *vc in m_viewControllers)
{
if(vc != [m_activeViewController]
[vc didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
Khi nút menu được khai thác để tôi làm cho sự chuyển tiếp giữa ViewControllers.
- (void)onMenuItemTapped:(id)sender
{
UIViewController *vc = [m_viewControllers objectAtIndex:sender.tag];
vc.view.frame = m_content.frame;
[self addChildViewController:vc];
[self transitionFromViewController:m_activeViewController toViewController:vc duration:0 options:UIViewAnimationOptionTransitionNone animations:nil completion:^(BOOL finished) {
[vc didMoveToParentViewController:self];
[m_activeViewController removeFromParentViewController];
m_activeViewController = vc;
}];
}
Quá trình chuyển đổi này hoạt động bình thường sau khi thay đổi định hướng, ngay cả khi chúng không hoạt động. Tuy nhiên, một trong những bộ điều khiển xem trẻ em này, được gọi là SecondCV, có UIPageViewController làm Bộ điều khiển xem trẻ em. Tôi có UIPageViewControllerDelegate và UIPageViewControllerDataSource thiết lập để SecondCV này và trong pageViewController: spineLocationForInterfaceOrientation: tôi trở UIPageViewControllerSpineLocationMin cho Portrait và UIPageViewControllerSpineLocationMid cho Cảnh. Xoay cho SecondVC này hoạt động chính xác khi nó hoạt động - có hai trang trên cảnh quan và một trang trên chế độ dọc được hiển thị chính xác. Nhưng khi SecondVC này không hoạt động thì vòng quay không chính xác. Ngay cả khi pageViewController: spineLocationForInterfaceOrientation: được gọi, vẫn còn một trang ở cả chế độ Chân dung và Phong cảnh. Tôi đang cố gắng sửa lỗi này một thời gian, nhưng tôi không thấy bất kỳ tùy chọn nào khác. Bạn có ý tưởng nào để sửa lỗi này không?
Cảm ơn bạn.
Tôi đang sử dụng bộ điều khiển xem trang, và tôi đã thêm VC vào một mảng, nhưng không biết cách thích hợp để chuyển đổi các VC khác nhau, làm cách nào tôi có thể chuyển sang trang tiếp theo. Bạn có thể vui lòng hướng dẫn tôi cho điều đó hoặc đăng một số mã mẫu của nó. –
[link] (https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html) Tôi nghĩ bạn có thể tìm thấy mọi thứ ở đây, nếu không, hãy liên hệ với tôi – DaNY
Tôi chưa có giải pháp nào, xin hãy xem câu hỏi của tôi nếu bạn có thể hướng dẫn tôi. "http://stackoverflow.com/questions/13776894/uipageviewcontroller-change-from-two-page-mode-to-one-page-mode-without-changi#comment18942540_13776894" –