Warnings for calling UIPanGestureRecognizer touchesBegan from subclass
In a custom subclass of UIPanGestureRecognizer, when I override touchesBegan with:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[[self view].superview brin开发者_开发百科gSubviewToFront:[self view]];
[super touchesBegan:touches withEvent:event];
}
The super line gets the warnings:
....warning: 'UIPanGestureRecognizer' may not respond to '-touchesBegan:withEvent:'
... Semantic Issue: 'UIPanGestureRecognizer' may not respond to 'touchesBegan:withEvent:'
Why is this?
The initial attempt at fixing this was by importing 'UIGestureRecognizerSubclass.h' as per the UIGestureRecognizer docs for subclasses of UIGestureRecognizer, but I get a 'No such file or directory' error when I try that.
I've got UIKit.framework included, and tried adding
#import <UIKit/UIKit.h>
but it doesn't work either.
Did I forget something?
This is what you need :
#import <UIKit/UIGestureRecognizerSubclass.h>
Also, here is a guide about event progamming in iOS, which contains instructions in order to write a gesture recognizer subclass.
I think you should explicitly import that file:
#import <UIKit/UIGestureRecognizerSubclass.h>
From UIGestureRecognizer Reference:
You may create a subclass that UIGestureRecognizer that recognizes a distinctive gesture—for example, a “check mark” gesture. If you are going to create such a concrete gesture recognizer, be sure to import the UIGestureRecognizerSubclass.h header file. This header declares all the methods and properties a subclass must either override, call, or reset.
精彩评论