首页 > 解决方案 > [UIImageView setScrollSpeed:]:发送到实例的无法识别的选择器-Objective C

问题描述

在此处输入图像描述

在这里,我需要单击蓝点 imageview。Leftside scrollView 应该开始滚动。
下面我添加了我使用 TableViewCell 的代码

MyMedsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyMedsTableViewCell" forIndexPath:indexPath];
cell.autoScrolling.hidden = NO;

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapping:)];
singleTap.numberOfTapsRequired = 1;
[cell.threedot setUserInteractionEnabled:YES];
[cell.threedot addGestureRecognizer:singleTap];

在这里我添加了我的 TableViewCell 的头文件

#import <UIKit/UIKit.h>
#import "CustomView.h"
#import <AutoScrollLabel/CBAutoScrollLabel.h>

@interface MyMedsTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet CBAutoScrollLabel *autoScroll;
@property (weak, nonatomic) IBOutlet UIImageView *threedot;

下面我添加了单击imageview后用来调用单元格属性的方法

-(void)singleTapping:(UIGestureRecognizer *)recognizer {
    CBAutoScrollLabel *autoScroll = (CBAutoScrollLabel*)recognizer.view;
    autoScroll.scrollSpeed = 30;
    NSLog(@"image clicked");
}

在这里我添加了我的错误日志

*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIImageView setScrollSpeed:]:无法识别的选择器发送到实例 0x7fe274cac530”

我尝试了不同的方法,但仍然出现此错误。有人可以帮忙吗?

标签: iosobjective-c

解决方案


您正在将您的 UITapGestureRecognizer 添加到 UIImageView

[cell.threedot addGestureRecognizer:singleTap];

您应该将其添加到您的 CBAutoScrollLabel

[cell.autoScroll addGestureRecognizer:singleTap];

推荐阅读