Reputation: 484
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
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) is from tapGestureRecognizer._imp
This is happening on multiple devices running iOS 8.1 . The source is compiled on Xcode 6.
Here is how I declare the UITapGestureRecognizer:
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
[myView addGestureRecognizer:tapGestureRecognizer];
And here is the method:
- (void)viewTapped:(UITapGestureRecognizer *)sender { }
The UITapGestureRecognizer is placed on a SKView;
Here is the stack trace: http://imageshack.com/a/img903/3622/X9QFX0.png
Upvotes: 1
Views: 1334
Reputation:
you can use cast as example: action as MyTapGesture
var gestureRecognizer = new MyTapGesture((action) =>
{
myEvent(action as MyTapGesture);
});
gestureRecognizer.Name = name;
and the class MyTapGesture be reemplazed to UITapGestureRecognizer
using System;
using UIKit;
namespace ETracker.Libraries
{
public class MyTapGesture: UITapGestureRecognizer
{
public string Name { get; set; }
public MyTapGesture()
{
}
public MyTapGesture(Action<UITapGestureRecognizer> action) : base(action)
{
}
}
}
Upvotes: 0
Reputation: 11
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.
Upvotes: 1
Reputation: 4203
you are trying to run a selector called name
on a UITapGestureRecognizer
instance, but UITapGestureRecognizer
doesn't have such a selector and that's why your program is crashing. Check where you are calling name
(probably inside viewTapped
) and make sure you are applying it on the correct object.
Upvotes: 0