UITableView does not automatically deselect the selected row when the table re-appears

前端 未结 7 572
感动是毒
感动是毒 2021-02-03 17:45

Normally a selected row in a UITableView gets deselected with an animation when the user pops back from the detail view.

However, in my case where I have a

7条回答
  •  一生所求
    2021-02-03 18:10

    When your main ViewController is from type UITableViewController, it has a property clearsSelectionOnViewWillAppear, which is per default YES - so it will clear the selection automatically.

    This property is not available for an UITableView, i guess it's because it has no ViewWillAppear method either.

    A UIViewController doesn't need this property because it has no UITableView originally.

    conclusion: you'll have to implement it by yourself when you do not use a UITableViewController.

提交回复
热议问题