Krutika Sonawala
Krutika Sonawala

Reputation: 1155

Setting delegate for UIGestureRecognizer giving warning

setting delegate for UITapGesture giving warning

Assigning to 'id<UIGestureRecognizerDelegate>_Nullable' from incompatible type 'TopPlayersViewController *const+strong'

Here is my code :

UITapGestureRecognizer *tapOtherPlayers = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapcollectionViewOtherPlayers:)];
tapOtherPlayers.delegate = self;
[tapOtherPlayers setNumberOfTapsRequired:1];
[collectionViewOtherPlayers addGestureRecognizer:tapOtherPlayers];

Upvotes: 1

Views: 1003

Answers (2)

Ashish Thummar
Ashish Thummar

Reputation: 431

Make "tapOtherPlayers" Variable as global and set UIGestureRecognizerDelegate delegate as bellow.

@interface ViewController ()<UIGestureRecognizerDelegate>{
    UITapGestureRecognizer *tapOtherPlayers;
}

@end

@implementation ViewController
- (void)viewDidLoad {

    tapOtherPlayers = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapcollectionViewOtherPlayers:)];
    tapOtherPlayers.delegate = self;
    [tapOtherPlayers setNumberOfTapsRequired:1];
    [collectionViewOtherPlayers addGestureRecognizer:tapOtherPlayers];
}

Hope this will help you...

Upvotes: 1

Balaji Ramakrishnan
Balaji Ramakrishnan

Reputation: 1949

You need to add UIGestureRecogniserDelegate in your .h file as following :

enter image description here

Hope it helps..

Upvotes: 6

Related Questions