I have a UIView which is supposed to cover the whole device (UIWindow) to support an image zoom in/out effect I'm doing using core animation where a user taps a button on a UITableViewCell and I zoom the associated image.
The zooming is performing flawlessly, what I haven't been able to figure out is why the subview is still in portrait mode even though the device is in landscape. An illustration below:
I do have a navigation controller but this view has been added to the UIWindow directly.
So think of a UIView as controlling part of the screen: drawing to it etc. A window is a mere container. The window does cover the entire screen (usually), the window is the root view in the view hierarchy (it is a UIView subclass).
The correct way to hide a window is to set the hidden property to YES. To remove it from UIApplication's windows property you just release the window (in ARC you set all references to nil). Of course you would want to have another window in place at this time.
You can read about some of the possible causes here:
Technical Q&A QA1688 - Why won't my UIViewController rotate with the device?
In your situation its probably the fact that you are adding the view as another subview to the window. Only the first subview gets the rotation events. What you can do is add it as a subview of the first window subview.
UIWindow* window = [UIApplication sharedApplication].keyWindow; if (!window) window = [[UIApplication sharedApplication].windows objectAtIndex:0]; [[[window subviews] objectAtIndex:0] addSubview:myView];
Beginning with iOS 6, only the topmost view controller (alongside the UIApplication object) participates in deciding whether to rotate in response to a change of the device's orientation.
https://developer.apple.com/library/content/qa/qa1688/_index.html
I have open sourced a pod named AGWindowView.
It will automatically deal with any rotation and framechanges so you won't have to worry about that.
It supports any combination of SDK's and iOS system versions. The relevant code can be found here: https://github.com/hfossli/AGWindowView/blob/master/Source/AGWindowView.m
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