Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
仅在播放视频时使用横向模式。xcode。ios 7_Xcode_Video_Ios7_Youtube_Landscape - Fatal编程技术网

仅在播放视频时使用横向模式。xcode。ios 7

仅在播放视频时使用横向模式。xcode。ios 7,xcode,video,ios7,youtube,landscape,Xcode,Video,Ios7,Youtube,Landscape,我使用youtube ios播放器助手:和 我一切都很顺利。视频播放很好! 但是 在项目设置中,我关闭了横向模式。因此,视频仅在纵向模式下播放。在iOS 7中播放视频时如何打开横向模式?我的解决方案: 它适用于iOS 7和iOS 8 为了播放YouTube上的视频,我使用了XCDYouTubeKit() AppDelegate.h: AppDelegate.m: MYTableViewController.m: xcdyoutubevideoplayervcontroller.m 您已经解决了这

我使用youtube ios播放器助手:和

我一切都很顺利。视频播放很好! 但是
在项目设置中,我关闭了横向模式。因此,视频仅在纵向模式下播放。在iOS 7中播放视频时如何打开横向模式?

我的解决方案:

它适用于iOS 7和iOS 8

为了播放YouTube上的视频,我使用了XCDYouTubeKit()

AppDelegate.h:

AppDelegate.m:

MYTableViewController.m:

xcdyoutubevideoplayervcontroller.m


您已经解决了这个问题吗?:)
@property (nonatomic) BOOL screenIsPortraitOnly;
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

    if (!self.screenIsPortraitOnly) {
        return UIInterfaceOrientationMaskPortrait;
    }
    else {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
}
#import "XCDYouTubeVideoPlayerViewController.h"
#import "XCDYouTubeKit.h"
#import "AppDelegate.h"

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:myIdYoutube];
    [[NSNotificationCenter defaultCenter] removeObserver:videoPlayerViewController  name:MPMoviePlayerPlaybackDidFinishNotification object:videoPlayerViewController.moviePlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoFinished) name:MPMoviePlayerPlaybackDidFinishNotification object:videoPlayerViewController.moviePlayer];
    videoPlayerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:videoPlayerViewController animated:YES completion:nil];
}

-(void)videoFinished
{
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.screenIsPortraitOnly = false;
    [self dismissViewControllerAnimated:YES completion:NULL];
}
#import "AppDelegate.h"

- (instancetype) initWithVideoIdentifier:(NSString *)videoIdentifier
{
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.screenIsPortraitOnly = true;
    if ([[[UIDevice currentDevice] systemVersion] integerValue] >= 8)
        self = [super initWithContentURL:nil];
    else
        self = [super init];

    if (!self)
        return nil;

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];

    if (videoIdentifier)
        self.videoIdentifier = videoIdentifier;

    return self;
}

- (void) viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.screenIsPortraitOnly = false;

    if (![self isBeingDismissed])
        return;

    [self.videoOperation cancel];
}