简体   繁体   中英

No Visible @interface for 'MainScene' declares the selector 'addGestureRecognizer:'

I am trying to use Gestures in a game that I am working on and when I use the following code it is giving me the above error.

UISwipeGestureRecognizer* up = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUp)];

[up setDirection:(UISwipeGestureRecognizerDirectionUp)];

[self addGestureRecognizer:up];

Please help.

You can only add Gesture Recognizers to views.

The last line in your code should be changed to:

[self.view addGestureRecognizer:up];

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