Implementation Peek for 3D Touch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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