0

I have UIWindow and it's rootViewController has blue background and allow all kind of orientation changing:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

Then I create new UIWindow with the new rootViewController (SecondViewController):

UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

SecondViewController* secondVC = [[SecondViewController alloc] init];

window.rootViewController = secondVC;

window.windowLevel = UIWindowLevelStatusBar;
[window makeKeyAndVisible];

enter image description here

SecondViewController allows only portrait orientation:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

The most important thing for me that SecondViewController view to be added like popup. So user can see background of previous VC.

But when I rotate device it asks both my VC for - (BOOL)shouldAutoRotate... method, and I got landscape mode, and status bar appears on landscape mode.

enter image description here

Ideally I wonder if deny rotating completely (blue, yellow, status bar won't rotate).

Please, help.

Injectios
  • 2,777
  • 1
  • 30
  • 50

1 Answers1

0

You can set allowed orientations in the project file.

  1. Click the toplevel of your project tree.
  2. Click your target in the left column under "targets"
  3. In the tab "Summary" you can select Supported Device Orientations"
fredrik
  • 17,537
  • 9
  • 51
  • 71
  • I can't manage project settings and other view controllers, because it will be third party app. And I'm developing static lib and have access only to SecondViewController. – Injectios Aug 21 '12 at 10:42
  • So in SecondViewController you need to deny orientations for the entire app or just hide your SecondViewController? – fredrik Aug 21 '12 at 10:44
  • in SecondViewController you need to deny orientations for the entire app, correct! – Injectios Aug 21 '12 at 10:47
  • In your SecondViewController you can only control that viewcontroller. I would guess that you could hack it somehow, but you should think about that you're are trying to do. If you develop a static library to use in other apps, the static library shouldn't control the behaviour of the app, but the other way around. – fredrik Aug 21 '12 at 10:52
  • Yes, but I only want to deny changing orientation if my viewcontroller view presented – Injectios Aug 21 '12 at 10:55
  • Don't know if this helps: http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation – fredrik Aug 21 '12 at 11:00