Question

Before closing this question as a duplicate just see I'm facing a serious issue for the past two days.

I'm following UIPageViewController with storyboards tutorial.

I tried to develop my UIPageviewController. I've to show a number of user photos. I don't want to show apagecontrol in bottom so I created a custom page control instead. When I try to set the index to the UIPageControl it's not working properly - getting some delay some times reaching 5th page only its updating so the counts are not proper

This is my datasource:

 -(UIViewController*)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{

    NSUInteger index = ((BMEnlargePhotoPageView*) viewController).pageIndex;
    [self.enlargePhotoPageControl setCurrentPage:index];

    if((index == 0 ) || (index==NSNotFound)){

        return nil;

    }
    index--;



    return [self viewControllerATindex:index];


}




-(UIViewController*)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{

    NSUInteger index = ((BMEnlargePhotoPageView*) viewController).pageIndex;
    [self.enlargePhotoPageControl setCurrentPage:index];


    if(index==NSNotFound){

        return nil;
    }

    index++;


    if(index==[self.userImages count])
    {
        return nil;
    }


    return [self viewControllerATindex:index];

}


- (BMEnlargePhotoPageView*)viewControllerATindex:(NSUInteger)index
{
       if(([self.userImages count]==0) || (index >= [self.userImages count])){

              }

    BMEnlargePhotoPageView *PageContentViewControl = [self.storyboard instantiateViewControllerWithIdentifier:@"EnlargePhoto"];

    PageContentViewControl.imageFIle =self.userImages[index];
    PageContentViewControl.pageIndex = index;


    return PageContentViewControl;

}

My other issue is that I want to find the current visible photos's index ID so that too I can't take properly - it's getting delayed value and is not correct.

Note: when I use animation page scroll everything works well but in scroll animation it's getting delayed but I want to show it as scroll only i tried many SO ansers nothing getting my problem some one guide or am i doing any wrong.

Was it helpful?

Solution

After long frustration week finally found which one good with iOS7 and don mind answering my question bcz no one answered so i supposed to fill the blank space.

In UIPageViewController there is delegate named didFinishAnimating: so in this there is a BOOL function which can identify your page turned completely or partially so using that BOOL you can check that and when you using even animation scroll it will be useful. Your code goes like this

- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed{

    if(completed){

        COntentViewController *enlarge =[self.pageViewController.viewControllers lastObject];
        self.enlargePhotoPageControl.currentPage =  enlarge.pageIndex;

    }

}

in this last object hold your last transmitted content if you partially scroll page the BOOL will not be get true it will indicate if the page scrolled completely this will help you those who wants to use custom page control. its working for me well how i expected set your pagecontrol index when the page scrolled completely unless the page indicator will not be set. It remains as last page count thx if i did any mistakes pls correct myself or even some good approach.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top