gpt4 book ai didi

objective-c - locationOfTouch 和 numberOfTouches

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:26:36 26 4
gpt4 key购买 nike

嗨我有这个识别器,设置了 2 个触摸,但它只返回一个,而不是两个 CGPoint

-(void)gestureLoad {

UIGestureRecognizer *recognizer;

recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(numTap2:)];
[(UITapGestureRecognizer *)recognizer setNumberOfTouchesRequired:2];
[self.view addGestureRecognizer:recognizer];
self.tapRecognizer = (UITapGestureRecognizer *)recognizer;
recognizer.delegate = self;
[recognizer release];

}

- (void)numTap2:(UITapGestureRecognizer *)recognizer {

CGPoint location = [recognizer locationInView:self.view];
NSLog(@"x %f y %f",location.x, location.y);

}

据我了解,我用这两种方法循环触摸次数,但我还没有弄清楚如何:

-(CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view {

}

-(NSUInteger)numberOfTouches {

}

非常感谢!

最佳答案

在 numTap2 中,使用:

CGPoint location = [recognizer locationOfTouch:touchIndex inView:self.view];

其中 touchIndex 为 0 或 1。

关于objective-c - locationOfTouch 和 numberOfTouches,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5979333/

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