Skip to content

Instantly share code, notes, and snippets.

@dimohamdy
Created April 27, 2019 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimohamdy/98756c9dfbb696cdbb8e362659865b6a to your computer and use it in GitHub Desktop.
Save dimohamdy/98756c9dfbb696cdbb8e362659865b6a to your computer and use it in GitHub Desktop.
weak var viewControllerPreviewing: UIViewControllerPreviewing!
override func awakeFromNib() {
super.awakeFromNib()
if self.traitCollection.forceTouchCapability == .available {
if viewControllerPreviewing != nil {
sourceVC.unregisterForPreviewing(withContext: viewControllerPreviewing)
}
viewControllerPreviewing = sourceVC.registerForPreviewing(with: self, sourceView: self)
}
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
if self.traitCollection.forceTouchCapability == .available {
if viewControllerPreviewing != nil {
sourceVC.unregisterForPreviewing(withContext: viewControllerPreviewing)
}
viewControllerPreviewing = sourceVC.registerForPreviewing(with: self, sourceView: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment