【发布时间】:2014-11-28 17:19:48
【问题描述】:
我在 iOS7 中开发的应用程序具有基于设备的强制定向: iphone -> 肖像 Ipad -> 横向
在 iOS8 中,如果我在 ipad 上的应用程序以纵向模式启动,它将以横向模式显示应用程序,但结果是:
如何修复 iOS 8 的方向?
【问题讨论】:
标签: ios ipad cocoa-touch uiinterfaceorientation
我在 iOS7 中开发的应用程序具有基于设备的强制定向: iphone -> 肖像 Ipad -> 横向
在 iOS8 中,如果我在 ipad 上的应用程序以纵向模式启动,它将以横向模式显示应用程序,但结果是:
如何修复 iOS 8 的方向?
【问题讨论】:
标签: ios ipad cocoa-touch uiinterfaceorientation
我不确定我是否可以回答我自己的问题,但我已经使用
解决了这个问题[self.window setFrame:[[UIScreen mainScreen] bounds]];
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法的末尾。
【讨论】:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if ([window.rootViewController isKindOfClass:[UINavigationController class] ]) {
if ([[window.rootViewController presentedViewController]
isKindOfClass:[SignatureViewController class]]) {
return UIInterfaceOrientationLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
return UIInterfaceOrientationMaskPortrait;
}
【讨论】:
我的问题与正在减号的 UIWindows 框架有关。所以在 MyViewController -(NSUInteger)supportedInterfaceOrientations Method 中编写如下代码
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self.view setFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
[appDel.window setFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
试试这个。
【讨论】: