gpt4 book ai didi

iphone - 如何在 UIImageView 上设置 UIGestureRecognizer?

转载 作者:行者123 更新时间:2023-12-01 17:27:37 25 4
gpt4 key购买 nike

如何添加 UIGestureRecognizer 以识别 UIImageView 顶部的左右滑动?我只需要在向左滑动时调用一个 Action ,在向右滑动时调用另一个 Action 。

最佳答案

创建 2 个滑动手势并将它们添加到您的 ImageView 中。

UISwipeGestureRecognizer * recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(myRightAction)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[myImageView addGestureRecognizer:recognizer];
[recognizer release];

UISwipeGestureRecognizer * recognizer2 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(myLeftAction)];
[recognizer2 setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[myImageView addGestureRecognizer:recognizer2];
[recognizer2 release];

关于iphone - 如何在 UIImageView 上设置 UIGestureRecognizer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8369908/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com