Peek and Pop is working with a UISearchController
. However, Peek and Pop stops working once you start searching the table using updateSearchResults
.
I've extended Apple's Table Search with UISearchController demo to support Peek and Pop as an example:
Problem is when I start searching the table, Peek and Pop doesn't work anymore. It just select highlights it:
The updates I made were to MainTableViewController
are:
class MainTableViewController: BaseTableViewController, UISearchBarDelegate, UISearchControllerDelegate, UISearchResultsUpdating {
override func viewDidLoad() {
super.viewDidLoad()
...
if traitCollection.forceTouchCapability == .available {
registerForPreviewing(with: self, sourceView: tableView)
}
}
}
extension MainTableViewController: UIViewControllerPreviewingDelegate {
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let indexPath = tableView?.indexPathForRow(at: location),
let cell = tableView?.cellForRow(at: indexPath),
let controller = storyboard?.instantiateViewController(withIdentifier: "DetailViewController") as? DetailViewController
else { return nil }
previewingContext.sourceRect = cell.frame
controller.product = products[0]
return controller
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
guard let controller = viewControllerToCommit as? DetailViewController else { return }
controller.product = products[0]
show(controller, sender: self)
}
}
Is the search context controller interfering with peek and pop (could even be the keyboard)? I can get it to work when the table initially all data, but it does not once I start using the search. I attached a working sample here if you want to run it and see the issue.