Skip to content

Instantly share code, notes, and snippets.

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 =[indexPath.row]
var detailViewCntrlr: UIViewController?
switch selectedData.type {
case .List:
detailViewCntrlr = self.storyboard?.instantiateViewControllerWithIdentifier("DETAIL_LIST_SCREEN")
case .Web:
detailViewCntrlr = self.storyboard?.instantiateViewControllerWithIdentifier("DETAIL_WEB_SCREEN")
case .Content:
detailViewCntrlr = self.storyboard?.instantiateViewControllerWithIdentifier("DETAIL_CONTENT_SCREEN")
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