2013-03-20 102 views
1

我有一個應用程序的旋轉配置是動態定義的,因此我無法在項目文件中設置支持的旋轉。如何防止iOS 6中的全屏視頻旋轉

所以我必須處理新shouldRotate方法(感謝蘋果!)

但是,儘管已經重寫這些來自於什麼,但肖像顯示無法充分UI。全屏顯示視頻視圖並旋轉時。視頻將旋轉至靜止。

是否有另一種方法可以專門從旋轉預覽視頻?

+1

您正在使用哪個視頻班級?你可以發佈有關'shouldRotate'方法的代碼嗎? – abellina 2013-03-20 13:26:53

+0

MPMoviePlayerController - 關於應該旋轉的代碼,假設我返回NO,因爲這總是結果在這種情況下 – 2013-03-20 13:40:27

+0

我沒有嘗試過這一點,但我相信你想MPMoviePlayerViewController代替。 http://stackoverflow.com/questions/3019200/how-to-rotate-an-mpmovieplayercontroller – abellina 2013-03-20 13:42:43

回答

0

這是一個使用MPMoviePlayerViewController子類支持縱向和縱向顛倒(但您可以輕鬆更改蒙版)的實現。 這適用於iOS 6,正如你建議的,以前的版本有不同的旋轉選擇器。

用法:

NSURL* url = [NSURL URLWithString:@"your_movie"]; 
MovieViewController* mvc = [[MovieViewController alloc] initWithContentURL:url]; 

// I did this from the app delegate. 
// You could push this view controller, present it modally, etc. 

[self.window setRootViewController:mvc]; 

MovieViewController.h

#import <UIKit/UIKit.h> 
#import <MediaPlayer/MediaPlayer.h> 

@interface MovieViewController : MPMoviePlayerViewController 

- (id)initWithContentURL: (NSURL*) url; 

@end 

MovieViewController.m

#import "MovieViewController.h" 
#import <MediaPlayer/MediaPlayer.h> 

@interface MovieViewController() 

@end 

@implementation MovieViewController 

- (id)initWithContentURL: (NSURL*) url 
{ 
    self = [super initWithContentURL: url]; 
    if (self) { 
     // Custom initialization 


    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // Do any additional setup after loading the view. 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 
/* 
    ROTATION CODE 
*/ 
- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

- (NSInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; 
} 


@end 

結果(注旋轉的項目啓用爲所有ro ):

enter image description here

+0

這是一個合適的問題答案,它不能解決我的特殊問題,但對大多數人來說會是一個更好的答案 – 2013-03-20 17:01:38