2012-10-15 52 views
1

我有一個在縱向模式下的一些視圖的應用程序,我想在橫向模式下呈現模態視圖控制器......對於IOS 5.0和5.1完美的,在IOS 6中它打開模式查看,但在肖像模式。你需要知道:我用故事板,我設置的VC景觀... 在應用程序委託我說:在景觀模式下使用IOS 6中的故事板呈現modalViewController

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w 
{return UIInterfaceOrientationMaskPortrait;} 

如果我添加| UIInterfaceOrientationMaskLandscape,我能夠在其他視圖旋轉的應用程序。

然後爲總結我禁用了所有支持的接口方向.. 在這裏,我試圖設置肖像和風景左,並運作良好,但在這種情況下,我可以旋轉到左側,並回到肖像的所有視圖。

,我想在景觀午餐這在視圖控制器後,我有這樣的方法IOS 6:

-(NSUInteger)supportedInterfaceOrientations 
{return UIInterfaceOrientationLandscapeLeft;} 

-(BOOL)shouldAutorotate 
{return YES;} 

和運行時,我點擊按鈕,午餐modalView後,我得到這個錯誤:「支持方向與應用程序沒有共同的方向,並且應該手動返回YES「

我知道的是關於在該方法上返回YES,但如果我設置NO,則不會發生任何事情。 我想考慮一下:我的應用程序需要在iOS 5及更高版本上工作。

有人可以幫我嗎? 任何建議是欣賞它;)

非常感謝

+0

大家好,我通過添加一個新的導航控制器(在故事板),然後通過這個新的導航控制器呈現模式實現。希望你可以管理這個。祝你好運;) – Bonnke

回答

3
- (void)viewWillAppear:(BOOL)animated { 
[super viewWillAppear:animated]; 
[self transformView2ToLandscape];} 

-(void) transformView2ToLandscape { 

NSInteger rotationDirection; 
UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation]; 

if(currentOrientation == UIDeviceOrientationLandscapeLeft){ 
    rotationDirection = 1; 
}else { 
    rotationDirection = -1; 
} 

CGAffineTransform transform = [arController.viewController.view transform]; 
transform = CGAffineTransformRotate(transform, degreesToRadians(rotationDirection * 90)); 
[arController.viewController.view setTransform: transform];} 

這工作對我很好。