Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Implementation Peek for 3D Touch
func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let indexPath = self.tableView.indexPathForRowAtPoint(location), cell = self.tableView.cellForRowAtIndexPath(indexPath) else { return nil }
let selectedData = self.data[indexPath.row]
var detailViewCntrlr: UIViewController?
switch selectedData.type {
case .List:
detailViewCntrlr = self.storyboard?.instantiateViewControllerWithIdentifier("DETAIL_LIST_SCREEN")
break
case .Web:
detailViewCntrlr = self.storyboard?.instantiateViewControllerWithIdentifier("DETAIL_WEB_SCREEN")
break
case .Content:
detailViewCntrlr = self.storyboard?.instantiateViewControllerWithIdentifier("DETAIL_CONTENT_SCREEN")
break
}
guard detailViewCntrlr != nil else { return nil }
detailViewCntrlr!.preferredContentSize = CGSizeMake(0.0, 0.0)
previewingContext.sourceRect = cell.frame
return detailViewCntrlr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment