开发者

warning: class 'CardController' does not implement the 'UIGestureRecognizerDelegate' protocol

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:

  1. 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.
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜