Sign in to follow this  

Gesture recognition causes my app to crash.

Recommended Posts

I'm still pretty new to gesture recognition, and I've never needed it until now.  So, I've found various examples on the net, and when I try to implement it, my app just crashes when I touch the screen.  So anyway, this is what I did.


I added this to viewDidLoad

// Create and initialize a tap gesture
    UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
                                             initWithTarget:self action:@selector(respondToTapGesture:)];
    // Specify that the gesture must be a single tap
    tapRecognizer.numberOfTapsRequired = 1;
    // Add the tap gesture recognizer to the view
    [self.view addGestureRecognizer:tapRecognizer];

Then I added this to the ViewController

- (void)respondToTapGesture:(UIGestureRecognizer *)gesture
    // Do whatever

What happens is I get a crash.  More specifically, I get an EXC_BAD_ACCESS.


[attachment=23338:Screen Shot 2014-08-27 at 9.11.42 AM.png]


That's the stack trace, if that helps.  I have absolutely no idea why this isn't working, when all of the examples appear to be working fine.  Did I forget to add something to plist?



Share this post

Link to post
Share on other sites

Erica Sadun is a friend of mine who helped me get my book deal and has given me advice on writing my first book.

She wrote this:


I haven’t used gestures directly as they are not useful in video games, but that covers the subject fairly exhaustively and may be of help.



L. Spiro

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this