ios – Navigate by tapping on the dots of UIPageControl


I’ve carried out a UIPageControl as a outlet in my code. Now I need to have the aptitude the place I can navigate to a selected view controller by tapping a dot within the UIPageControl.

To attain this I’ve added an IBAction to the UIPageControl and within the implementation I am taking the currentPage to load that particular view controller

-(IBAction)pageControlDotDidTap:(id)sender {
    if (![sender isKindOfClass:[UIPageControl class]]) {
        return;
    }
    
    NSInteger selectedPage = [(UIPageControl *)sender currentPage];
    
    // obtained the currentPage now I can load the view controller

}

However the issue is by default UIPageControl strikes 1 web page at a time. Hyperlink: https://developer.apple.com/documentation/uikit/uipagecontrol#:~:textual content=Thepercent20pagepercent20controlpercent20advancespercent20onlypercent20onepercent20pagepercent20inpercent20eitherpercent20direction.

So after I’m on the rightmost dot, If I clicked on the leftmost dot it solely navigate to the second rightmost dot.

Is it potential to attain that, the dot I am clicking the UIPageControl will return that dot quantity as an alternative of transferring one a time?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles