In my test demo, I put a UITableView into UIViewController in storyboard. When I test demo on my iPhone, I pressed one cell in tableView, I got this error in picture
In func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController?
method, I use
guard let indexPath = tableView.indexPathForRowAtPoint(location), cell = tableView.cellForRowAtIndexPath(indexPath) else { return nil }
to get the pressed cell in UITableView.
I really appreciate if you give me any answers!
When you register your source view, are you adding the view controller's view or your tableview? I had a similar issue on a collection view but once I registered the actual view and not the view controller's view, the behavior was corrected.
so in other words..
This gave me wrong cell
registerForPreviewingWithDelegate(self, sourceView:self.view)
This corrected the behavior
registerForPreviewingWithDelegate(self, sourceView:self.tableView)