There's a decent amount of information online about using size classes in XCode for iOS 8, but little or nothing about reading, interpreting, or manipulating size classes in code. Is doing so in code even an option?
Of course, once again I find what I've been looking for after(!) I post on SO :)
In iOS 8, there is in fact a class UITraitCollection
that has information about size class.
To get access to it when it changes, any UIViewController
can override methods of either of 2 protocols that UIViewController
implements:
UIContentContainer - viewWillTransitionToTraitCollection:withTransitionCoordinator:
UITraitEnvironment - traitCollectionDidChange:
Even easier, self.traitCollection
can be accessed within any UIViewController
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With