iphone - 在UITableViewController中的viewWillAppear之后未调用didDeselectRowAtIndexPath

标签 iphone ios uitableview viewwillappear

我正在使用UITableViewController子类,并将clearsSelectionOnViewWillAppear设置为YES(默认值)。

viewWillAppear:中自动取消选择的单元格时,如何对其进行更改?

最佳答案

tableView:didDeselectRowAtIndexPath:子类中的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:

关于iphone - 在UITableViewController中的viewWillAppear之后未调用didDeselectRowAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11886354/

相关文章:

iphone - 系统声音 ID 音量

c# - Monotouch : Setting Window in pre 5. 0 设备

ios - 从后台线程添加到 UITableView 中的 UIStackView

ios - 如何在 if/switch 语句中声明一个将变为全局的变量?

iphone - 如何使用 UIActionSheet 传递参数?

ios - 模糊效果在模拟器中显示,但在 iPhone 上不显示

ios - 我收到错误 : instance member websitetext can not be used on type 'ViewController4

ios - 在 UITableView 中单击的事件

iphone - 如何在移动后更改表格 View 单元格的背景颜色?

ios - 使用 Xcode 如何导出应用程序并与模拟器中的团队成员共享?