Created
April 27, 2019 16:03
-
-
Save dimohamdy/98756c9dfbb696cdbb8e362659865b6a to your computer and use it in GitHub Desktop.
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
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