3

我正在尝试让我的 youtube 视频以横向模式播放。我关闭了左右横向以支持设备方向,因为如果它打开,每个视图都可以横向。我正在为 iOS 6 构建这个。如何让我的视频横向播放。

这是我的代码

#import "VideoTViewController.h"
#import "HCYoutubeParser.h"
#import <MediaPlayer/MediaPlayer.h>

@interface VideoTViewController ()

@end

@implementation VideoTViewController
@synthesize tLabel;

-(IBAction)playVideo
{

    NSDictionary *videos = [HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=zz_bJ58LfCg&feature=youtu.be"]];

    MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[videos objectForKey:@"medium"]]];

    [self presentViewController:mp animated:YES completion:nil];
}

编辑:

我做了以下事情:

开了一个新班

AboutNavViewController(它是 UiNavigationController 的子类)

#import "AboutNavViewController.h"

@interface AboutNavViewController ()

@end

@implementation AboutNavViewController


- (BOOL)shouldAutorotate {
    return NO;
}

- (BOOL)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
@end

在我的 aboutviewcontroller (子类化 uiviewcontroller)

#import "AboutViewController.h"
#import "AboutNavViewController.h"

@interface AboutViewController ()

@end

@implementation AboutViewController
@synthesize aLabel;

- (void)viewDidLoad
{
    [super viewDidLoad];

    CGRect frame = CGRectMake(0, 0, 320, 44);
    aLabel = [[UILabel alloc] initWithFrame:frame];
    aLabel.backgroundColor = [UIColor clearColor];
    [aLabel setFont:[UIFont fontWithName:@"SerifGothic LT Black" size:25]];
    aLabel.text = @"Sephardi Jews";
    aLabel.textAlignment = NSTextAlignmentCenter;
    aLabel.textColor =[UIColor whiteColor];
    self.navigationItem.titleView = aLabel;

    AboutNavViewController *about = [[AboutNavViewController alloc] init];

    [self presentViewController:about animated:YES completion:nil];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

@end

我收到以下错误:

开始/结束外观转换的不平衡调用。

我究竟做错了什么?

4

1 回答 1

10

注意:您必须将横向左右添加到 Info.plist 中支持的界面方向才能正常工作。

系统通过将应用程序的supportedInterfaceOrientationsForWindow: 方法返回的值与最顶部全屏控制器的supportedInterfaceOrientations 方法返回的值相交来确定是否支持方向。

从上一个答案中添加了 iOS 6 自动旋转方法”

@interface MyMovieViewController : MPMoviePlayerViewController
@end

@implementation MyMovieViewController

- (BOOL)shouldAutorotate 
{
    return YES;
}

- (NSInteger)supportedInterfaceOrientations 
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

@end
于 2012-09-24T16:58:15.823 回答