如何让pageController控制UIImageView?
Posted
技术标签:
【中文标题】如何让pageController控制UIImageView?【英文标题】:How to let the pageController control the UIImageView? 【发布时间】:2010-05-03 12:38:26 【问题描述】:我想要一个UIImageView向左滑动,UIImageView会改变图像,此时pageController +1,如果向右滑动,pageContoller -1,并显示上一个图像... ...我该如何实现它?有什么简单的代码吗?你。
【问题讨论】:
【参考方案1】:只需将 UISwipeGestureRecognizer 附加到 UIImageView。当手势识别器触发时,您将检查它的方向,然后更改图像并相应地更新 pageController。
【讨论】:
【参考方案2】:UIGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(next:)];
UISwipeGestureRecognizer *swipeLeftRecognizer = (UISwipeGestureRecognizer *)recognizer;
swipeLeftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeftRecognizer];
swipeLeftRecognizer=nil;
[recognizer release];
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(prev:)];
UISwipeGestureRecognizer *swipeRightRecognizer = (UISwipeGestureRecognizer *)recognizer;
swipeRightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRightRecognizer];
swipeLeftRecognizer=nil;
[recognizer release];
【讨论】:
以上是关于如何让pageController控制UIImageView?的主要内容,如果未能解决你的问题,请参考以下文章
如何让它工作我正在尝试使用 pagecontrol 制作幻灯片,但索引显示错误
collectionView swift中的PageControl