Patrick Patrick - 6 months ago 37
iOS Question

Blacked-out interface rotation when using second UIWindow with rootViewController

(iOS 7.0.3, Xcode 5.0.1)

I have a second UIWindow in my app used to display a custom magnifier above the status bar. However, once I set the rootViewController of this window (for interface rotation & some other stuff), the main window goes black during the interface rotation animation.

To reproduce: create single view iOS application and add the following to the main UIViewController.

// To @interface:
@property (nonatomic, strong) UIWindow *secondWindow;
// In viewDidLoad:
self.secondWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.secondWindow.rootViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
self.secondWindow.hidden = NO;

Any help appreciated.


I will add another answer, because I have found a workaround that actually works. Set the window's background color, as well as the view controller's view's background color to a color with an alpha of 0. Do not use clearColor, but rather use something like greenColor] colorWithAlphaComponent:0.0]; It works.