gpt4 book ai didi

iphone - 通过触摸移动事件限制拖动距离

转载 作者:行者123 更新时间:2023-12-03 20:52:01 24 4
gpt4 key购买 nike

为了使用 OpenGL 编辑图像,我提供了用户交互,以便当用户移动手指时,图像会根据拖动方向进行编辑。但我想限制拖动。例如,用户应该只编辑某些部分 Nose ,如果拖动不受限制,我的图像纹理会变得扭曲,因为用户有机会在屏幕或脸上拖动他/她的手指(更具体地说)。

//这是代码

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
count++;
NSLog(@"touches moved called");
UITouch *touch = [[touches allObjects] objectAtIndex:0];
if(count>2)
{
NSLog(@"Entered");
count=0;
self.view.userInteractionEnabled=NO;
}
else{
updatepoint = [touch locationInView:self.view];
mousex = updatepoint.x;
mousey = self.view.bounds.size.height-updatepoint.y;
grab = [self ripple_grab:mousex:mousey];
[self drawFrame];
}
}

最佳答案

我找到了解决方案

这是我更新的代码。如果还有其他方法请给我建议。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
count = 0;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
count++;
NSLog(@"touches moved called");
UITouch *touch = [[touches allObjects] objectAtIndex:0];
if (count > 6)
{
NSLog(@"Entered");
// count=0;
// self.view.userInteractionEnabled = NO;
//NSLog(@"line skipped");
}
else{
NSLog(@"else Entered");
updatepoint = [touch locationInView:self.view];
mousex = updatepoint.x;
mousey = self.view.bounds.size.height-updatepoint.y;
grab = [self ripple_grab:mousex:mousey];
[self drawFrame];
}
}

关于iphone - 通过触摸移动事件限制拖动距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12141970/

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