Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageViewController setViewControllers, UIPageControl not showing right current number

I'am using a UIPageViewController with horizontal scrolling... as long as the user scrolls, the UIPageControl works correctly, problem occurs when jumping programmatically to next or previous page

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

Than the index of the UIPageControl isn't right (i would provide the index by myself, but cannot access the UIPageViewController's UIPageControl)

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

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

How to get the current dot index of the UIPageControl right, when changing the UIPageViewController page programmatically?

like image 510
Peter Lapisu Avatar asked Jan 28 '14 13:01

Peter Lapisu


People also ask

How do I navigate from page to page in uipageviewcontroller?

When navigating from page to page, the page view controller uses the transition that you specify to animate the change. In tvOS, the UIPageViewController class provides only a way to swipe between full-screen content pages.

What is the uipageviewcontroller in tvOS?

In tvOS, the UIPageViewController class provides only a way to swipe between full-screen content pages. Unlike in iOS, a user cannot interact with or move focus between items on each page.

What is the uipageviewcontrollerdelegate protocol?

The delegate of a page view controller must adopt the UIPageViewControllerDelegate protocol. These methods allow the delegate to receive a notification when the device orientation changes and when the user navigates to a new page.

How do I programmatically navigate from page to page in iOS?

Page view controller–navigation can be controlled programmatically by your app or directly by the user using gestures. When navigating from page to page, the page view controller uses the transition that you specify to animate the change. In tvOS, the UIPageViewController class provides only a way to swipe between full-screen content pages.


1 Answers

ok, turned out that i misunderstood one delegate method

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
    return [(IntroPageViewController *)[pageViewController.viewControllers firstObject] index];
}
like image 158
Peter Lapisu Avatar answered Oct 21 '22 21:10

Peter Lapisu