2012-09-17 45 views
0

我有一個自定義單元格,它上面有一個按鈕。我想嘗試用長按來代替。自定義表格單元格,自定義XIB和長按識別器 - 不能使它們一起工作

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

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]; 

    } 

然後我做了原有的廈門國際銀行的副本。刪除了該按鈕。投下了UILongPressGestureRecognizer的細胞,並通過控制拖動窗體創建一個目標識別該文件的所有者:

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

enter image description here 但是,一旦我開始產生細胞,我得到這個錯誤:

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

這是怎麼回事?

回答

0

我從來沒有找到或找到答案這樣的問題。我所學到的是這個計劃可能存在缺陷。顯然,將您贏得的手勢識別器與桌子視圖混合在一起會造成災難,至少是心碎。

我的情況是,我決定採用一個固定的佈局,只包含將顯示的項目數量。在我的應用程序中,我真的只是使用表格出於歷史原因,並且從不需要顯示超過7個項目。

解決方法和黑客,但它爲我工作。