简体   繁体   中英

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

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:)]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM