2013-08-25 28 views
1

我想創建一個自定義的segue來改變並將我的下一個視圖鎖定到肖像模式,不管設備如何旋轉。我能創造我的UIStoryBoardSegue文件,但現在我堅持的代碼從橫向到縱向切換...這是我做過什麼至今:自定義Segue人像模式

-(void) perform 

{ 
     self.appDelegate = [[UIApplication sharedApplication] delegate]; 
     UIViewController *source = (UIViewController *) self.sourceViewController; 
     UIViewController *destination = (UIViewController *) self.destinationViewController; 



    } 

現在我堅持...幫助!

+0

你是從第一個控制器推到第二個控制器還是模態顯示?重寫supportedInterfaceOrientations適用於模態演示。我不知道你想要做什麼是可能的,因爲它是旋轉的導航控制器本身。試圖用自定義的segue來實現它不會比其他嘗試更好。 – rdelmar

回答

0

我不知道你是否爲書面方式iOS 6的或每iOS 6中,但如果是iOS 6中,嘗試將以下代碼放置在您試圖設置其方向的視圖控制器中。

- (BOOL) shouldAutorotate 
{ 
return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; 
} 

現在上面的方法具有所有的蒙版,你可以刪除你不需要的蒙版。真的沒有必要再訪問應用程序委託進行輪換設置。希望這可以幫助你實現你想要的。

0

一種方式是重載一個視圖控制器子類的supportedDeviceOrientations方法這樣

- (NSUInteger)supportedInterfaceOrientations { 
    return UIDeviceOrientationPortrait; 
} 
+0

您的代碼適用於iOS 6以上版本。自此,方向由掩碼定義。 –