I'm creating a subclass of UIView that needs to relayout its subviews when the orientation changes.
it needs to be able to "plug in anywhere" without any extra code so I'd rather not rely on the UIViewController methods to detect the autorotation
Is there anyway for the UIView to know when the orientation has changed?
How about a notification like this to detect the orientation change??
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
But, before that you need to register for generating notifications like this.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
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