gpt4 book ai didi

ios - 自定义单元格和 dequeueCellWithIdentifier 中的 UIGestureRecognizer 冲突

转载 作者:技术小花猫 更新时间:2023-10-29 11:23:35 25 4
gpt4 key购买 nike

我在 UITableView 中注册了一个自定义 UITableViewCell(.h、.m、.xib)。

现在我需要在单元格内使用自定义 UIImage 并将手势识别器附加到它(我不能使用 UIButton)。问题是如果它在运行时我得到一个

Terminating app due to uncaught exception  'NSInternalInconsistencyException', 
reason: 'invalid nib registered for identifier (CustomCell) -
nib must contain exactly one top level object which must be a UITableViewCell instance'

如果我删除了单元格正常工作的手势,我相信这是一个 cocoa 错误,我现在将尝试以编程方式实例化它,但我想问题在于手势识别器与xib

enter image description here

您知道其他界面构建器解决方法吗?

最佳答案

在 UIImage 和上启用用户交互在 awakeFromNib 作品中以编程方式添加手势识别器

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleImageTap:)];
tap.cancelsTouchesInView = YES;
tap.numberOfTapsRequired = 1;
tap.delegate = self;
[self.imagePicture addGestureRecognizer:tap];

但我想知道它不起作用的原因。我会等待接受。

关于ios - 自定义单元格和 dequeueCellWithIdentifier 中的 UIGestureRecognizer 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31965341/

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