[英]didDeselectRowAtIndexPath not called after viewWillAppear in UITableViewController
我正在使用UITableViewController
子類, clearsSelectionOnViewWillAppear
設置為YES
(默認值)。
在viewWillAppear:
上自動取消選擇時,如何更改取消選擇的單元格?
tableView:didDeselectRowAtIndexPath:
在viewWillAppear:
自動取消選擇單元格時不調用viewWillAppear:
在UITableViewController
子類中。
在這種情況下,使用以下代碼對取消選擇進行更改:
- (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:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.