0

我有一个自定义单元格,上面有一个按钮。我想尝试使用长按。

创建单元格的代码如下所示:

CustomCell *cell = (CustomCell *)[aTableView dequeueReusableCellWithIdentifier:@"CustomCell"];
if (!cell) 
{
    cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] lastObject];

}

(ETC)

所以我这样做了:

    CustomCell *cell = (CustomCell *)[aTableView dequeueReusableCellWithIdentifier:@"CustomCell"];
    if (!cell) 
    {
//      cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] lastObject];
        cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCellDwellToSpeak" owner:self options:nil] lastObject];

    }

然后我复制了原始的xib。删除了按钮。在单元格上放置一个 UILongPressGestureRecognizer,并通过从识别器向文件所有者控制拖动来创建目标:

- (IBAction)longPress:(UILongPressGestureRecognizer *)sender;

在此处输入图像描述 但是,一旦我开始生成单元格,就会出现以下错误:

TypOHD[41541:c07] -[UILongPressGestureRecognizer label]: unrecognized selector sent to instance 0x17d0be60

那是怎么回事?

4

1 回答 1

0

我从来没有得到或找到这个问题的答案。我学到的是这个计划有潜在的缺陷。显然,将您赢得的手势识别器与表格视图混合在一起是灾难的根源,或者至少是令人心碎的。

在我的情况下,我决定使用一个固定的布局,它只包含无论如何都会显示的项目数量。在我的应用程序中,出于历史原因,我实际上只使用了一个表格,并且从不需要显示超过 7 个项目。

一种解决方法和一种技巧,但它对我有用。

于 2012-09-24T05:46:12.367 回答