1
我使用的UITableViewController
子類clearsSelectionOnViewWillAppear
設置爲YES
(默認值)。didDeselectRowAtIndexPath在viewWillAppear在UITableViewController中不調用
如何在取消選中的單元格在viewWillAppear:
上自動取消選中時對其進行更改?
我使用的UITableViewController
子類clearsSelectionOnViewWillAppear
設置爲YES
(默認值)。didDeselectRowAtIndexPath在viewWillAppear在UITableViewController中不調用
如何在取消選中的單元格在viewWillAppear:
上自動取消選中時對其進行更改?
tableView:didDeselectRowAtIndexPath:
未在UITableViewController
子類中的viewWillAppear:
上自動取消選中單元時調用。
使用下面的代碼,以使在這種情況下取消更改:
- (void) viewWillAppear:(BOOL)animated {
// HACK: Need to be called before super if the selection is cleared on viewWillAppear.
UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:self.tableView.indexPathForSelectedRow];
// Change the cell
[super viewWillAppear:animated];
}
在一般情況下,如果使用deselectRowAtIndexPath:animated:
,tableView:didDeselectRowAtIndexPath:
不會被調用。