In my app i am trying to detect swipe gesture to navigate to the next page ...
Please find my below code below
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
[cardsGridView addGestureRecognizer:swipeRight];
when i run my application, i get the below warning...
warning: class 'MyGesture' does not implement the 'UIGestureRecognizerDeleg开发者_运维问答ate' protocol
Kindly help me up that what i am missing here.
UPDATE1 : can anybody pls show me a working code to detect the swipe....
The UIGestureRecognizerDelegate
protocol only defines optional methods. There are now two ways to get rid of the warning:
- Do not set the delegate at all if you do not need any of those optional delegate methods. Your
swipeRightAction
method call will work anyway as you specify the target and the selector in the initializer. If you need to set the delegate, indicate in the header file of your delegate class that the class implements the protocol by specifying it in angle brackets after your superclass name:
@interface YourClass : UIViewController <UIGestureRecognizerDelegate> { ... }
Edit: Thanks, I forgot to escape the angle brackets.
精彩评论