我有一個帶有自定義附件按鈕的UITableView。選擇表格單元格時,附件按鈕處於高亮狀態。好吧,這是件好事。當選擇另一個單元格時,導致第一個單元格取消選擇,則附件按鈕不會變回未被加亮的狀態。取消該行後,如何在UITableView中取消選中附件?
下面是一個屏幕截圖,顯示不再被選中的單元格(玫瑰),但仍選擇了附件按鈕。
我已經嘗試解決這裏建議。 AccessoryDetailDisclosureButton not deselecting after I call deselectRowAtIndexPath它不起作用。我重新加載了表格中的每個單元格,但它仍不會將附件按鈕置於不亮的狀態。
我已經明確地試過在單元格中的按鈕,不管是在新選擇按鈕的選擇器還是在tableView:accessoryButtonTappedForRowWithIndexPath:
方法中。沒有快樂。
下面是一個創建按鈕的代碼:
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {
...
UIButton *folderButton = [UIButton buttonWithType: UIButtonTypeCustom];
folderButton.frame = CGRectMake(0.0, 0.0, 33.0, 33.0);
[folderButton setImage: [UIImage imageNamed: @"open_document.png"] forState: UIControlStateNormal];
[folderButton addTarget: self action: @selector(documentButtonAction:) forControlEvents: UIControlEventTouchUpInside];
[folderButton setTag: [program tag]];
cell.accessoryView = folderButton;
...
}
我到目前爲止發現的唯一的解決辦法是將突出顯示的按鈕圖像設置爲未突出顯示的圖像,但是這很可怕,太,因爲按鈕在點擊時不會突出顯示。
如何取消配件按鈕的高亮顯示?
正如在帖子中提到的,我確實嘗試過這種方法。它不起作用。 – Mike 2013-03-14 16:55:09
奇怪的是,我嘗試重新加載整個表而不是行,並且_did_工作。奇怪的。 [self.programTableView reloadData]; – Mike 2013-03-14 17:01:17