gpt4 book ai didi

IOS:手势获得更多浏览量

转载 作者:行者123 更新时间:2023-11-28 23:08:56 25 4
gpt4 key购买 nike

我有这个代码:

UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
[recognizer setNumberOfTouchesRequired:1];
[view1 addGestureRecognizer:recognizer];
[view2 addGestureRecognizer:recognizer];
[view3 addGestureRecognizer:recognizer];
[recognizer release];

- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer{ //do something}

它只在 view3 中识别滑动,为什么?我该如何解决这个问题?我应该为每个 View 做一个新的滑动手势吗?但我有 20 次观看。

最佳答案

如果您有 20 个 View ,它们可能存储在数组或其他东西中?如果是,您尝试过这样的方法吗?

 for (unsigned i = 0; i < [yourViewsArray count]; i++){
UIView *view = [yourViewsArray objectAtIndex:i];
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
[recognizer setNumberOfTouchesRequired:1];
[view addGestureRecognizer:recognizer];
[recognizer release];
}

这样你就可以为每个 View 添加一个新的识别器

关于IOS:手势获得更多浏览量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8725074/

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