1

整個應用程序僅支持肖像方向,只有播放視頻需要支持所有方向。 該應用程序在完全肖像模式下在iOS < 6.0上運行完美,現在由於需要支持iOS 6.0的MPMoviePlayerViewController(視頻播放)的自動旋轉方向,所以我搜索了很多東西,而我獲得如下解決方案,所以我申請者在我的應用程序,ios:MPMoviePlayerViewController對整個肖像應用程序的所有方向支持

1)支持所有方位的plist或目標

2)添加下面的定位功能,人像支持

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

- (BOOL)shouldAutorotate 
{ 
    return NO; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationPortrait; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

3)覆蓋MPMoviePlayerViewController類,並添加了所有合適的定位方法以支持。

4)將下面的方法放在AppDelegate文件中,如果找到MPMoviePlayerViewController的對象,則返回橫向。

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { } 

但終於沒有成功! - 我無法以橫向模式播放視頻,只有肖像支持整個應用程序。

我不知道爲什麼它不旋轉?有什麼我錯過了設置?

回答

0

我最近不得不在我開發的應用程序中做相反的事情,我必須強制視頻回放才能以橫向模式顯示。我所做的就是讓我的應用程序支持所有的方向,而是覆蓋我的mpMoviePlayerViews shouldAutorotateToInterfaceOrientation方法返回YES僅適用於橫向。

既然你想做相反的事情,那麼如何讓你的應用程序兼容potrait和landscape?但是將你的常規視圖限制在只有potrait? (並因此避免你的問題,讓您的mpmovieplayerview旋轉)我認爲應該有可能創建一個父視圖類,您的常規視圖可以繼承,並在您的父類只是覆蓋shouldAutorotateToInterfaceOrientation只支持/返回YES potrait模式。

相關問題