gpt4 book ai didi

iphone开发-UItapGestureRecognizer(顺时针或逆时针检测)?

转载 作者:行者123 更新时间:2023-12-03 20:33:04 30 4
gpt4 key购买 nike

有没有办法检测用户所做的旋转是顺时针还是逆时针方向???

我搜索过但找不到答案!

我的代码如下所示:

 UIGestureRecognizer *recognizer;
recognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(spin)];
[self.rotating addGestureRecognizer:recognizer];
[recognizer release];

最佳答案

rotation 属性会告诉您 rotation以弧度为单位。负值表示顺时针旋转,正值表示逆时针旋转。

示例:

UIGestureRecognizer *recognizer;
recognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(spin:)]; // <-- Note the colon after the method name
[self.rotating addGestureRecognizer:recognizer];
[recognizer release];

- (void)spin:(UIGestureRecognizer *)gestureRecognizer {
CGFloat rotation = gestureRecognizer.rotation;
if (rotation < 0) {
// clockwise
} else {
// counter-clockwise
}
}

关于iphone开发-UItapGestureRecognizer(顺时针或逆时针检测)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6390457/

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