为 UIGestureRecognizer 设置委托发出警告

Kru*_*ala 1 objective-c ios uitapgesturerecognizer

为 UITapGesture 设置委托发出警告

从不兼容的类型“TopPlayersViewController *const+strong”分配给“id<UIGestureRecognizerDelegate>_Nullable”

这是我的代码:

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

Bal*_*nan 5

您需要在 .h 文件中添加 UIGestureRecogniserDelegate 如下:

在此处输入图片说明

希望能帮助到你..