gpt4 book ai didi

ios - UIGestures 与手动控制

转载 作者:行者123 更新时间:2023-11-28 23:01:42 26 4
gpt4 key购买 nike

UIGesturesRecognizer 有效地取代了

提供给我们的任何手动控制是否正确?
- touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:

只是在这里寻找确认。

谢谢

最佳答案

如果您说这些方法不会被调用,那是不正确的。

如果您说 UIGesture 可以执行此方法执行的操作,那么答案是肯定的,使用 UIGestures 您可以执行您发布的此方法可以执行的所有操作。并且可能以一种简单的方式编写代码:)

可以获取手势状态、 View 等。使用 UIGestures 很容易知道是点击、长按、滑动等。

看看 Reference

编辑:

一个给你的例子,添加一个 PanGesture,将在之后处理:

UIPanGestureRecognizer* pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)];
[self.view addGestureRecognizer:pan];

你的方法将处理平移,将接收手势,并且看起来像:

-(void)panGestureHandler:(UIPanGestureRecognizer *)gesture{
CGPoint postionInView = [gesture translationInView:self.view];
[yourView setCenter:postionInView];
}

关于ios - UIGestures 与手动控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9899608/

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