MSU*_*dog 1 uitouch ios uiswipegesturerecognizer uipangesturerecognizer
我在touchesEnded方法中调用了一个名为addProjectile的方法.addProjectile接收touchesEnded方法接收的触摸的NSSet.为简单起见,我只在相关代码中发布了我的问题.所以,要明确一点:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self addProjectile:touches]; }
-(void) addProjectile:(NSSet *)touches {//do stuff }
Run Code Online (Sandbox Code Playgroud)
我想在名为swipeRight的UIPanGestureRecognizer方法的末尾调用addProjectile并发送正确的NSSet触摸.
-(void)swipedRight:(UIPanGestureRecognizer *)recognizer {
CGPoint panned=[recognizer translationInView:self.view];
if(panned.x>50){//do stuff }
else {
NSSet *touches; <-- this is what I need to get
[self addProjectile:touches];
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何在swipedRight结束时获得正确的NSSet触摸(这是用户拿起他/她的手指):正确执行addProjectile方法.
看看UIGestureRecognizerState.这就是你所需要的.
示例代码(假设在这里,您只需要在用户完成平移时需要触摸点,即抬起他的手指):
-(void)swipedRight:(UIPanGestureRecognizer *)panGesture {
if ([panGesture state] == UIGestureRecognizerStateEnded) {
//User touch has ended
CGPoint touchUpPoint = [panGesture translationInView:self.view]; // or `locationInView:`
NSLog(@"__TOUCH_END_POINT__ = %@", NSStringFromCGPoint(touchUpPoint));
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1735 次 |
| 最近记录: |