2012-09-22 128 views
0

我正在使用xcode 4.5的故事板,在iOS 6上構建應用程序。我在mpvideoviewcontroller中有一個視頻。當我觀看視頻時,它會變成風景,但對於所有其他視圖(我喜歡歌曲和新聞),如何爲所有其他標籤製作人像?我只是想讓視頻成爲風景畫。有沒有我失蹤的東西,我有。將每個選項卡上的方向設置爲縱向,在xcode項目摘要屏幕上左右啓用。而且我添加了這一行代碼,以便我只想成爲肖像。如何僅製作所有視圖肖像模式

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return NO; 
} 

有什麼建議嗎?

供參考:如果我在Xcode的摘要頁面中將方向更改爲僅肖像模式,則每個視圖都是肖像模式,並且我希望我的視頻視圖處於橫向而非縱向模式。

+0

我會做更多的研究,你的話題,但我知道,雖然只是作爲一個快速響應的的iOS 6 SDK的shouldAutorotateToInterfaceOrientation已被廢棄,現在你應該使用 - 如果(BOOL)shouldAutorotate方法 – Zack

+0

您問題與iOS 6旋轉問題相關,請參考[this] [1]鏈接。 [1]:http://stackoverflow.com/questions/11544382/ios-6-screen-rotation-without-using-storyboard – iBapu

回答

0

更改該方法只爲肖像模式返回true:

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation { 

    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
+0

這不起作用。我在iOS 6上。上述方法折舊。 – jakife

1

的iOS 6支持這一項上的AppDelegate

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
     // check if you are in video page --> return landscape 
     return (isVideoPage)?UIInterfaceOrientationMaskAllButUpsideDown:UIInterfaceOrientationMaskPortrait; 
    } 

希望可以幫助。

0

我想你可以做這樣的事情,其中​​在我的代碼prevLayer與視頻源的觀點,因爲這個對象是AVCapture類型有setOrientation,但你可以做一個變換/旋轉一定程度上符合目前的方向,希望能幫助到你。

-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

    switch ([[UIDevice currentDevice]orientation]) { 
     case UIDeviceOrientationLandscapeLeft: 
      [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeRight]; 
      break; 
     case UIDeviceOrientationLandscapeRight: 
      [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeLeft]; 
      break; 
     default: 
      [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeLeft]; 
      break; 
    } 

} 
相關問題