這個問題困擾了我兩天,以為無解了,看了一天的英文資料,最后發現這是apple的BUG!shit
解決方案是這樣:連續調用setViewController兩次。
__weak UIPageViewController* pvcw = pvc;
[pvc setViewControllers:@[page]
direction:UIPageViewControllerNavigationDirectionForward
animated:YES completion:^(BOOL finished) {
UIPageViewController* pvcs = pvcw;
if (!pvcs) return;
dispatch_async(dispatch_get_main_queue(), ^{
[pvcs setViewControllers:@[page]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil];
});
}];
對于蘋果的這種BUG,我只能表示蛋疼!如果你要學習UIPageViewController,在xcode中新建一個page Based工程就是了。
參考資料:
iOSBook-chpter19