2010-10-02 31 views
5

我一直在努力與細胞disclosue按鈕...首先,它是說這是因爲我用的是貶值:細胞看法披露按鈕與對策研究方法

-(UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath { 
return UITableViewCellAccessoryDetailDisclosureButton; 
} 

所以我評論說出來,並添加了披露使用在configureCell細胞:

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
cell.editingAccessoryType = UITableViewCellAccessoryNone; 

但是現在我披露按鈕什麼都不做。我需要添加什麼才能讓揭示按鈕生效。我所有的Google搜索都提出了其他折舊方法。任何幫助或指針將不勝感激。

回答

14

如果你真的想要一個詳細披露按鈕,請確保你你的附件類型設置爲UITableViewCellAccessoryDetailDisclosureButton。 (您的示例代碼顯示爲UITableViewCellAccessoryDisclosureIndicator。)您在表格視圖代理的tableView:accessoryButtonTappedForRowWithIndexPath:方法中處理詳細披露按鈕。您在表格視圖代表tableView:didSelectRowAtIndexPath:方法中處理行選擇(無論配件視圖是什麼)。

+0

這就是我出錯的地方。我的圖標只是>不是>,因此當我將類型更改爲UITableViewCellAccessoryDe​​tailDisclosureButton時,它的工作方式與之前一樣。感謝您的高舉 – Designer023 2010-10-02 20:55:58

3

使用此方法在您的表視圖代表

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath 
+0

我用這個已經,原來,因爲我使用的是UITableViewCellAccessoryDisclosureIndicator而不是UITableViewCellAccessoryDe​​tailDisclosureButton,它沒有調用它:)所有修復和現在工作。感謝您的幫助 – Designer023 2010-10-02 20:57:42

0

委託方法在雨燕3.0

func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) { 

} 

但對於使用該委託: 你可以用下面的兩個附件類型之一:

cell.accessoryType = .detailDisclosureButton 
cell.accessoryType = .detailButton 
相關問題