Reputation: 2537
The document of UITraitEnvironment says:
This method is called automatically when the current trait collection changes. Overriding this method provides you with a way to customize behavior when the trait collection associated with the view changes. If you do not override this method, no special behavior is performed.
But when I rotate the simulator this overridden method in my UIView subclass is not called.
My code looks like:
override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
println("______________________________")
}
Did I miss anything? Or I understand the API doc wrongly? thx for shedding light on it.
Upvotes: 4
Views: 6075
Reputation: 191
Are you tested on the iPad?
Probably because on the iPad the trait collection are all Regular for vertical and horizontal on both portrait and landscape.
Try this method it should work.
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
Upvotes: 19