使用带有rootViewController的第二个UIWindow时,黑屏的界面旋转

Pat*_*pel 6 objective-c uiviewcontroller uiwindow ios

(iOS 7.0.3,Xcode 5.0.1)

我的应用程序中有第二个UIWindow,用于在状态栏上方显示自定义放大镜.但是,一旦我设置了这个窗口的rootViewController(用于界面旋转和其他一些东西),主窗口在界面旋转动画期间变黑.

要重现:创建单视图iOS应用程序并将以下内容添加到主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;
Run Code Online (Sandbox Code Playgroud)

任何帮助赞赏.

Leo*_*ica 6

我将添加另一个答案,因为我找到了一个实际可行的解决方法.将窗口的背景颜色以及视图控制器视图的背景颜色设置为alpha为0的颜色.不要使用clearColor,而是使用类似greenColor] colorWithAlphaComponent:0.0];它的工作方式.

  • 我有rootViewController.view.backgroundColor甚至没有设置为任何(nil)和UIWindow.backgroundColor = clearColor.都好. (2认同)