2014-01-28 56 views
7

我'使用帶有水平滾動一個UIPageViewController ......只要用戶滾動時,UIPageControl正常工作,程序跳轉到下一個或前一個頁面時出現問題UIPageViewController setViewControllers,UIPageControl沒有顯示正確的當前號碼

[self.pageViewController setViewControllers:@[[self viewControllerWithIndex:index]] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil]; 

比起UIPageControl的指數是不正確的(我會自己提供的指數,但不能訪問UIPageViewController的UIPageControl)

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController { 
    return IntroScreensCount; 
} 

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController { 
    return 0; 
} 

如何獲得當以編程方式更改UIPageViewController頁面時,UIPageControl右側的當前點索引?

+1

顯示您的委託方法 –

+0

編輯,但代表們有什麼關係呢,因爲他們只提供最小和最大的索引,而不是當前一個 –

+0

好吧,現在我明白了 –

回答

10

OK,原來,我誤會了一個委託方法

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController { 
    return [(IntroPageViewController *)[pageViewController.viewControllers firstObject] index]; 
}