我有一个管理UISearchBar和UITableView的UIViewController。我读到苹果公司不鼓励在你的应用程序中使用多个UIViewControllers来管理你的应用程序,所以我没有使用UITableViewController来管理UITableView。相反,我在自己的UIViewController中实现了UITableViewDelegate
和UITableViewDataSource
协议。
我的问题是,既然我不再使用UITableViewController,我应该如何实际更改clearsSelectionOnViewWillAppear
行为?此属性是UITableViewController的一部分。
发布于 2011-07-14 06:02:03
只需调用
[myTableView deselectRowAtIndexPath:[myTableView indexPathForSelectedRow] animated:YES];
在您的viewWillAppear:
方法中。
发布于 2015-08-31 00:33:33
下面是Swift的代码:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if let indexPath = tableView.indexPathForSelectedRow() {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
}
发布于 2012-07-09 09:54:49
您很可能会重写viewWillAppear:animated
方法并错过[super viewWillAppear:animated]
调用。
https://stackoverflow.com/questions/6686203
复制相似问题