2013-07-16 28 views
0

我在表格的每個表格視圖單元格上添加了一個自定義的UIButton。我將這個按鈕分配給AccessoryDe​​tailDisclosureButton。所以在堅果殼中,它是一個自定義的AccessoryDe​​tailDisclosureButton。這是我如何的cellForRowAtIndexPath做:AccessoryDe​​tailDisclosureButton action

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ; 
    UIButton *ACC = [UIButton buttonWithType:UIButtonTypeCustom]; 
    ACC.frame = CGRectMake(0, 0, 25, 25); 
    if(iPhone) 
    { 
     [ACC setImage:[UIImage imageNamed:@"select_arrow.png"] forState:UIControlStateNormal]; 
    } 
    else 
    { 
     ACC.frame = CGRectMake(0, 0, 60, 60); 

     [ACC setImage:[UIImage imageNamed:@"[email protected]"] forState:UIControlStateNormal]; 
    } 
    cell.accessoryView = ACC; 
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
} 

現在的問題是, 我希望把AccessoryDe​​tailDisclosureButton同樣的動作是在didSelectRowAtIndexPath方法 我會寫didSelectRowAtIndexPath方法的身體accessoryButtonTappedForRowWithIndexPath方法,但它不會工作。

現在,如果我評論cell.accessoryView = ACC;在上面的代碼中。它會正常工作。但我無法從附件按鈕中刪除圖像

我該如何擺脫它。

任何幫助將高度讚賞

感謝

回答

0

你有一個目標,並選擇添加到您的按鈕。

[ACC addTarget:self action:@selector(handleRowSelection:) 
    forControlEvents: UIControlEventTouchUpInside]; 

這就是說,你應該避免引入不添加功能的新UI元素。

相關問題