2

I want to add a view above key window, so it can display on every page. But when changing the orientation, the view won't rotate accordingly. I think this is caused after ios6 which apple changes the rotation method. So my question is how to solve the rotation issue, or if there is alternative simple way to present a view above every pages. Thanks.

Updated for Nick C:

I followed your solution by creating two UIWindow objects. But when rotating the device, it will show black background and the translucent top window. When the rotation animation is done, the original window shows up. I think it is bad for user experience. Do you have any idea about how to solve this? Here is my code:

    self.topWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.watermarkViewController = [[WatermarkViewController alloc] init];
    self.topWindow.rootViewController = self.watermarkViewController;
    self.topWindow.windowLevel = UIWindowLevelAlert;
    [self.topWindow makeKeyAndVisible];
    self.topWindow.userInteractionEnabled = NO;

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
yibuyiqu
  • 728
  • 1
  • 7
  • 20

2 Answers2

2

I think your issue is in iPad, and you can add subview to the window like this.

 [[[[[UIApplication sharedApplication].windows objectAtIndex:0] subviews] objectAtIndex:0] addSubview:self.myView];

You could get more information from here

Community
  • 1
  • 1
Guru
  • 4,693
  • 3
  • 25
  • 45
  • It solves the rotation issue, but if I present another UIViewController, the cover view will disappeared. Can I ask in your code, what's the first subview of the window? – yibuyiqu Mar 15 '13 at 05:11
1

Initialize a UIWindow and set windowLevel to UIWindowLevelAlert Create a UIViewController subclass to hold your view, make it the rootViewController of the window, and override the -[UIViewController supportedInterfaceOrientations] method

Nick C
  • 645
  • 3
  • 6