正在使用iOS6設備xcode 4.5 &山獅子mac。 並在我的應用程序開始在肖像模式(3屏幕)。 但第4屏幕應在景觀,並應支持景觀左&景觀權。在iOS6中的橫向模式中的應用程序
大多數解釋都顯示如何旋轉。
在appddelegate正在使用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
navigationController.navigationBar.tintColor = [UIColor blackColor];
// Set RootViewController to window
if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[self.window addSubview: navigationController.view];
}
else
{
// use this mehod on ios6
[self.window setRootViewController:navigationController];
}
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.shouldRotate) //shouldRotate is my flag
{
self.shouldRotate = NO;
return (UIInterfaceOrientationMaskLandscapeRight);
}
return (UIInterfaceOrientationMaskPortrait);
}
,並在我的視圖控制器這應該是景觀和正在使用
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
appDelegate.shouldRotate = YES;
// Custom initialization
}
return self;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
在我viewcontrollers這是potrait都正常工作,其中正在使用
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
任何人都可以提出這樣做
在此先感謝
的'[self.window setRootViewController:navigationController ]'應該在iOS 4及更高版本上調用,所以只需刪除iOS 6的檢查,並一直使用'self.window.rootViewController'屬性。 – rckoenes
只需投入我的兩分錢,支持風景的應用程序就能支持整個應用程序的景觀。您不應該強迫用戶在工作流程中間輪換設備。 –
self.window.rootViewController = navigationController;通過使用這一個也不加載景觀景觀 –