gpt4 book ai didi

ios - UIlabel 中的 UITapGestureRecognizer 错误

转载 作者:行者123 更新时间:2023-12-02 08:36:33 27 4
gpt4 key购买 nike

我在 UILabel 上使用 UITapGestureRecognizer

但是当我点击UILabel时它崩溃了。

以下是我的代码。

UITapGestureRecognizer *gester = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moveToDetail:)];
gester.numberOfTapsRequired = 1;
[label addGestureRecognizer:gester];
label.userInteractionEnabled = YES;

以下是moveToDetail方法

- (void)moveToDetail:(id)sender {
}

以下是崩溃消息

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITapGestureRecognizer rootViewIfClass:]: unrecognized selector sent to instance

如何解决这个问题。

最佳答案

试试这个代码

UITapGestureRecognizer *gester = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moveToDetail)];
gester.numberOfTapsRequired = 1;
label.userInteractionEnabled = YES;
[label addGestureRecognizer:gester];

- (void)moveToDetail
{

}

关于ios - UIlabel 中的 UITapGestureRecognizer 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51166404/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com