Question

I'm trying to add the gesture recognizer to the main view but I'm getting this error:

No visible @interface for 'ViewController' declares the selector addGestureRecognizer error

on this line:

 [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(isTapped:)]];

any of you knows why of the error or how can I fix this error?

Was it helpful?

Solution

addGestureRecognizer is a method on UIView, not UIViewController.

Try

    [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(isTapped:)]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top