Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>UIView doesn't handle rotations, UIViewController does. So, all you need is to create a UIViewController, which implements shouldAutorotateToInterfaceOrientation and sets this controller as a rootViewController to your UIWindow</p> <p>Something like that:</p> <pre><code> UIViewController * vc = [[[MyViewController alloc] init] autorelease]; vc.view.frame = [[UIScreen mainScreen] bounds]; vc.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4]; //you vc.view initialization here UIWindow * window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; window.windowLevel = UIWindowLevelStatusBar; window.backgroundColor = [UIColor clearColor]; [window setRootViewController:vc]; [window makeKeyAndVisible]; </code></pre> <p>and I used this MyViewController, cause I want it to reflect changes of main application</p> <pre><code> @interface MyViewController : UIViewController @end @implementation MyViewController - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { UIWindow *window = ((UIWindow *)[[UIApplication sharedApplication].windows objectAtIndex:0]); UIViewController *controller = window.rootViewController; if (!controller) { NSLog(@"%@", @"I would like to get rootViewController of main window"); return YES; } return [controller shouldAutorotateToInterfaceOrientation:toInterfaceOrientation]; } @end </code></pre> <p>but you can always just return YES for any orientation or write your logic, if you wish.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload