UITapGestureRecognizer导致应用程序崩溃 [英] UITapGestureRecognizer causes app to crash

查看:560
本文介绍了UITapGestureRecognizer导致应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UITapGestureRecognizer导致应用程序在滑动完成时崩溃。在非常短的距离内完成的滑动不会导致任何问题,但是在较长距离上完成的操作会产生错误:

UITapGestureRecognizer causes app to crash when a swipe is done. Swipes done over very short distances do not cause any problems, but those done over a longer distance give the error :

 -[UITapRecognizer name]: unrecognized selector sent to instance 0x17ee27c0

其中0x17ee27c0是随机值。

where 0x17ee27c0 is a random value.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITapRecognizer name]: unrecognized selector sent to instance 0x17ee27c0'
*** First throw call stack:
(0x2cb7dc1f 0x3a328c8b 0x2cb83039 0x2cb80f57 0x2cab2df8 0x2feee1c1 0x2d7d01cf 0x3024822d 0x300671ad 0x30066bcd 0x3003d3dd 0x302b0c29 0x3003be39 0x2cb44377 0x2cb43787 0x2cb41ded 0x2ca90211 0x2ca90023 0x33e890a9 0x3009c1d1 0xdca87 0x3a8a8aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException

UITapRecognizer *(0x17ee27c0)来自tapGestureRecognizer._imp

UITapRecognizer * (0x17ee27c0) is from tapGestureRecognizer._imp

这是在运行iOS 8.1的多个设备上发生的。源码是在Xcode 6上编译的。

This is happening on multiple devices running iOS 8.1 . The source is compiled on Xcode 6.

这是我如何声明UITapGestureRecognizer:

Here is how I declare the UITapGestureRecognizer:

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
[myView addGestureRecognizer:tapGestureRecognizer];      

这里是方法:

- (void)viewTapped:(UITapGestureRecognizer *)sender { }

UITapGestureRecognizer放置在SKView上;

The UITapGestureRecognizer is placed on a SKView;

这里是堆栈跟踪:
http://imageshack.com/a/img903/3622/X9QFX0.png

推荐答案

我在我的一个SpriteKit游戏中有同样的问题,它是因为你在场景之间的过渡期间使用手势,我解决了它通过设置 gestureRecognizer.enable 属性(文档)转换为 NO

I had the same issue in one of my SpriteKit Games, it is caused when you use gestures during transition between scenes, i solved it by setting gestureRecognizer.enable property (documentation) to NO before the transition.

这篇关于UITapGestureRecognizer导致应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆