我想支持iOS 6旋轉。麻煩的是,我一直在瀏覽大量文檔和堆棧溢出問題,但還沒有發現任何深度解決方案。我只看到,我應該這兩種方法添加到我的視圖控制器類 - 但是,如果我沒有記錯的話,他們不會以同樣的方式操作作爲預iOS 6的方法:iOS 6旋轉:推視圖控制器
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll; // use what is appropriate for you.
}
我應用程序目前使用以下代碼在iOS6之前旋轉。請注意,我使用界面方向參數來確定是否要推送視圖控制器。我如何在iOS 6旋轉代表中實現這一點?
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
UIInterfaceOrientation toOrientation = self.interfaceOrientation;
if (self.tabBarController.view.subviews.count >= 2)
{
UIView *tabBar = [self.tabBarController.view.subviews objectAtIndex:1];
if(toOrientation != UIInterfaceOrientationLandscapeLeft && toOrientation != UIInterfaceOrientationLandscapeRight)
{
CUSTOM_DEBUG_LOG("\n\nRotated back to Portrait");
tabBar.hidden = FALSE;
}
}
}
- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
CUSTOM_DEBUG_LOG("\nView going landscape");
ScrollViewController *s = [[ScrollViewController alloc] initWithNibName:@"ScrollViewController" bundle:nil];
[self.navigationController pushViewController:s animated:NO];
[s release];
self.tabBarController.tabBar.hidden = YES;
self.navigationController.navigationBar.hidden = YES;
}
}
觀看關於視圖控制器的WWDC 2012電影。 – matt
我想我並沒有恰當地說出我的問題,因爲我的應用程序在這裏沒有任何答案。我基本上無法在iOS中獲得輪換工作,我認爲willAnimate ...函數也被棄用。原來,他們不是。所以我的應用程序仍然有效萬歲? 不幸的是,我在我的頁面上有巨大的不美觀的白色條紋,我需要擺脫它。時間發佈另一個問題。 –