iOS - UIPageControl 页面指示器点不随 UISwipeGestureRecognizer 改变 [英] iOS - UIPageControl page indicator dots not changing with UISwipeGestureRecognizer
问题描述
我正在使用 UIPageControl
和 UISwipeGestureRecognizer
在我的应用程序的 2 个视图控制器之间切换.我修改了本教程,没有使用滚动视图.
I am using UIPageControl
and UISwipeGestureRecognizer
to switch between 2 view controllers of my application. I have modified this tutorial without using scroll view.
我有两个问题:
1) 使用滑动手势会改变视图控制器/页面,而不是指示当前页面的点.我试过了
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) 我正在使用 - (IBAction)changePage:(id)sender
来更改页面.我想知道如何在单击某个点时切换到页面.我的意思是说,点击点 1,我应该转到第一个视图控制器,点击点 2,我应该导航到第二个视图控制器.
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.
推荐答案
您需要知道点的位置并在其上添加按钮或点击手势.我不知道如何计算点在哪里 - 没有公共 API.从用户的角度来看,这些点太小而无法点击.你不应该这样做.但是可以随意向控件的任一端添加按钮/手势 - 如果它们是正常大小...
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...
这篇关于iOS - UIPageControl 页面指示器点不随 UISwipeGestureRecognizer 改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!