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 に答える