我已经为iPhone和iPad创建了一个通用的应用程序。在此应用程序中,iPhone为navigation类型,iPad为tab bar类型。iPhone支持横向和纵向,而iPad应用程序仅支持横向。
在iPad中,我在登录窗口(当前模型视图)之后显示TabBarController,当我第一次运行iPad应用程序时,它总是以纵向模式运行。即使我将方向模式设置为横向,也应该自动旋转为横向。
因此,请任何人可以建议我哪里错了,或者我如何在横向模式中强制显示视图。
发布于 2012-11-21 16:50:22
我使用下面的代码强制更改了方向。它对我来说工作得很好:
if ([[UIDevice currentDevice] respondsToSelector:@selector (setOrientation:)]) {
SEL selector = NSSelectorFromString (@" setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int Val = UIInterfaceOrientationLandscapeRight;
[invocation setArgument:& val atIndex:2];
[invocation invoke];
}谢谢
发布于 2012-11-20 19:35:54
只需将以下代码添加到您的应用程序委托.m文件中
self.window.rootViewController = self.navController;
and also remove [self.window addSubview:self.navController.view];
this will definitely working.. https://stackoverflow.com/questions/13471382
复制相似问题