3

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

wrong cell view

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!

JerryShi
  • 33
  • 4

1 Answers1

14

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)

SprayKid982
  • 333
  • 3
  • 16
  • Thanks for your answer, I have solved this problem by replacing the method of adding UITableView to a UIViewController with UITableViewController – JerryShi Nov 20 '15 at 07:14