Created
October 27, 2015 05:06
-
-
Save y8k/9e203413b10f16e9bd5b to your computer and use it in GitHub Desktop.
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