How to use UIPageControl with iCarousel?

狂风中的少年 提交于 2019-12-01 00:04:37

In the iCarousel carouselCurrentItemIndexUpdated: delegate method, set

pageControl.currentPage = carousel.currentItemIndex / 5

Then bind your pageControl action to a method like the one below:

- (IBAction)updatePage:(UIPageControl *)pageControl
{
    [carousel scrollToItemAtIndex:pageControl.currentPage * 5 aimated:YES];
}

If you're not using a nib file, you can bind the action using

[pageControl addTarget:self action:@selector(updatePage:) forControlEvents:UIControlEventValueChanged];

It's a good idea to set pageControl.defersCurrentPageDisplay = YES; as well to avoid flicker.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!