我看到很多关于这个主题的问题,但我无法找到解决我遇到的问题的方法。我创建了一个 iPad 应用程序,它应该是横向的——它在 iOS6 之前的任何操作系统上运行时都能正常工作,但在 iOS6 上,应用程序以纵向视图打开。此屏幕截图显示了我的意思(对不起,不是一个很好的解释)http://s1342.beta.photobucket.com/user/designbyria/media/ScreenShot2012-11-02at122113.png.html
我猜问题出在下面的代码中,但我不能确定。我已将支持的界面方向设置为仅横向左和横向右 - 但这不起作用。我也看了一下这里的问题,但没有运气..
我正在使用 xcode 和 cordova/phonegap
在 xcode 4.5 GM IOS 6 中将方向设置为横向模式
iOS 6 应用程序 - 如何处理 iPhone 5 的屏幕尺寸?
提前致谢!
/** * 这是应用程序启动后的主要启动,此处设置视图和设置。(首选 - iOS4 及更高版本) / - (BOOL) application:(UIApplication )application didFinishLaunchingWithOptions: (NSDictionary*)launchOptions {
NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]; NSString* 调用字符串 = nil;if (url && [url isKindOfClass:[NSURL class]]) { invokeString = [url absoluteString]; NSLog(@"iwill launchOptions = %@", url); } CGRect screenBounds = [[UIScreen mainScreen] bounds]; self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease]; self.window.autoresizesSubviews = YES; CGRect viewBounds = [[UIScreen mainScreen] applicationFrame]; self.viewController = [[[MainViewController alloc] init] autorelease]; self.viewController.useSplashScreen = YES; self.viewController.wwwFolderName = @"www"; self.viewController.startPage = @"index.html"; self.viewController.invokeString = invokeString; self.viewController.view.frame = viewBounds; // check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation BOOL forceStartupRotation = YES; UIDeviceOrientation curDevOrientation = [[UIDevice currentDevice] orientation]; if (UIDeviceOrientationUnknown == UIInterfaceOrientationLandscapeLeft) { // UIDevice isn't firing orientation notifications yet… go look at the status bar curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation]; } if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) { for (NSNumber *orient in self.viewController.supportedOrientations) { if ([orient intValue] == curDevOrientation) { forceStartupRotation = YES; break; } } } if (forceStartupRotation) { NSLog(@"supportedOrientations: %@", self.viewController.supportedOrientations); // The first item in the supportedOrientations array is the start orientation (guaranteed to be at least Portrait) UIInterfaceOrientation newOrient = [[self.viewController.supportedOrientations objectAtIndex:0]
整数值];NSLog(@"AppDelegate 强制状态栏到: %d from: %d", newOrient, curDevOrientation); [[UIApplication sharedApplication] setStatusBarOrientation:newOrient];
} [self.window addSubview:self.viewController.view]; [self.window makeKeyAndVisible]; return YES; }