簡體   English   中英

自定義表格單元格,自定義XIB和長按識別器-無法使它們一起工作

[英]Custom table cell, custom XIB and long press recognizer - can't make them work together

我有一個自定義單元格,上面有一個按鈕。 我想嘗試使用長按來代替。

創建單元格的代碼如下所示:

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

}

(等等)

所以我這樣做:

    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

那是怎么回事?

我從來沒有得到或找到這樣的問題的答案。 我確實了解到,該計划可能存在缺陷。 顯然,將贏得的手勢識別器與表格視圖混合在一起是造成災難或至少令人傷心的原因。

就我而言,我決定采用固定布局,該布局僅包含無論如何都會顯示的項目數。 無論如何,在我的應用程序中,我實際上只是出於歷史原因才使用表格,並且不需要顯示超過7個項目。

解決方法和破解,但對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM