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

StackOverflow https://stackoverflow.com/questions/21501105

سؤال

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?

هل كانت مفيدة؟

المحلول

addGestureRecognizer is a method on UIView, not UIViewController.

Try

    [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(isTapped:)]];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top