iOS - UIPageControl page indicator dots not changing with UISwipeGestureRecognizer

风流意气都作罢 提交于 2019-12-11 12:09:03

问题


I am using UIPageControl and UISwipeGestureRecognizer to switch between 2 view controllers of my application. I have modified this tutorial without using scroll view.

I have 2 issues:

1) Using the swipe gesture is changing the view controllers/pages but not the dots indicating the current page. I have tried

if (self.pageControl.currentPage == 0) {
 self.pageControl.currentPage = 1 
}

but I am not sure why it does not work. I have the outlet available

@property (strong, nonatomic) IBOutlet UIPageControl *pageControl;

2) I am using - (IBAction)changePage:(id)sender for changing the page. I would like to know how to change to a page on clicking on a certain dot. I mean to say that on clicking on dot 1, I should go to the first view controller and on clicking on dot 2, I should navigate to the second view controller.


回答1:


You need to know where the dots are and add buttons over them or tap gestures. I don't know how to work out where the dots are - there isn't a public API for that. And from a user point of view, the dots are too small to tap. You shouldn't do it. But feel free to add buttons / gestures to either end of the control - if they are a normal size...



来源:https://stackoverflow.com/questions/21193217/ios-uipagecontrol-page-indicator-dots-not-changing-with-uiswipegesturerecogniz

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