+ rotating_nav = [[[RotateyViewController alloc] initWithRotation:YES]
+ retain];
+ [window setRootViewController: rotating_nav];
+ [window setAutoresizesSubviews:YES];
+ [window setAutoresizingMask:
+ (UIViewAutoresizingFlexibleWidth |
+ UIViewAutoresizingFlexibleHeight)];
+
+ nonrotating_nav = [[[RotateyViewController alloc] initWithRotation:NO]
+ retain];
+ [nonrotating_nav setNavigationBarHidden:YES animated:NO];
+
+ /* We run the saver on a different UIWindow than the one the
+ SaverListController and preferences panels run on, because that's
+ the only way to make rotation work right. We want the system to
+ handle rotation of the UI stuff, but we want it to keep its hands
+ off of rotation of the savers. As of iOS 8, this seems to be the
+ only way to accomplish that.
+
+ Also, we need to create saverWindow with a portrait rectangle, always.
+ Note that [UIScreen bounds] returns rotated and scaled values.
+ */
+ UIScreen *screen = [UIScreen mainScreen];
+# ifndef __IPHONE_8_0 // iOS 7 SDK
+ NSRect frame = [screen bounds];
+ int ss = [screen scale];
+# else // iOS 8 SDK
+ NSRect frame = ([screen respondsToSelector:@selector(nativeBounds)]
+ ? [screen nativeBounds] // iOS 8
+ : [screen bounds]); // iOS 7
+ int ss = ([screen respondsToSelector:@selector(nativeScale)]
+ ? [screen nativeScale] // iOS 8
+ : [screen scale]); // iOS 7
+# endif // iOS 8 SDK
+ frame.size.width /= ss;
+ frame.size.height /= ss;
+ saverWindow = [[UIWindow alloc] initWithFrame:frame];
+ [saverWindow setRootViewController: nonrotating_nav];
+ [saverWindow setHidden:YES];
+
+ /* This view is the parent of the XScreenSaverView, and exists only
+ so that there is a black background behind it. Without this, when
+ rotation is in progress, the scrolling-list window's corners show
+ through in the corners.
+ */
+ backgroundView = [[[NSView class] alloc] initWithFrame:[saverWindow frame]];
+ [backgroundView setBackgroundColor:[NSColor blackColor]];