Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.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
Uitableview MPMoviePlayerViewController在风景中时解除肖像_Uitableview_Ios7_Mpmovieplayercontroller - Fatal编程技术网

Uitableview MPMoviePlayerViewController在风景中时解除肖像

Uitableview MPMoviePlayerViewController在风景中时解除肖像,uitableview,ios7,mpmovieplayercontroller,Uitableview,Ios7,Mpmovieplayercontroller,我有一个TableViewController,它只用于模式。现在我想在触摸手机时播放一段视频。 在我的应用程序委托中,我正在使用以下方法: - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([[self.window.rootViewController presentedViewController]

我有一个TableViewController,它只用于模式。现在我想在触摸手机时播放一段视频。 在我的应用程序委托中,我正在使用以下方法:

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

if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]]) {
    NSLog(@"ja1");
    return UIInterfaceOrientationMaskAllButUpsideDown;
} else {
    if ([[self.window.rootViewController presentedViewController] isKindOfClass:[UINavigationController class]]) {
        NSLog(@"ja2");

        // look for it inside UINavigationController
        UINavigationController *nc = (UINavigationController *)[self.window.rootViewController presentedViewController];

        // is at the top?
        if ([nc.topViewController isKindOfClass:[MPMoviePlayerViewController class]]) {
            NSLog(@"ja3");
            return UIInterfaceOrientationMaskAllButUpsideDown;

            // or it's presented from the top?
        } else if ([[nc.topViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]]) {
            NSLog(@"ja4");
            return UIInterfaceOrientationMaskAllButUpsideDown;
        }
    }
}
return UIInterfaceOrientationMaskPortrait;
}
使观看视频时转向风景成为可能

我从TableView中显示了MPMoviePlayerViewController的一个实例

- (void)playVideo {
NSURL *movieURL = [NSURL URLWithString:MYURL];
MPMoviePlayerViewController *c = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];

// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:c
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:c.moviePlayer];

// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(movieFinishedCallback:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:c.moviePlayer];

// Set the modal transition style of your choice
c.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

// Present the movie player view controller
[self presentViewController:c animated:YES completion:^{}];

// Start playback
[c.moviePlayer prepareToPlay];
[c.moviePlayer play];
}
现在我有一个问题,当我在横向模式下关闭MPMoviePlayerViewController时,我想将其旋转回纵向模式。但我的MasterViewController(=TableView)仍处于横向模式


你能帮帮我吗

在MasterViewController中实施以下定向方法。这将使您的MasterViewController保持纵向

- (BOOL)shouldAutorotate{
    return false;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
// Returns interface orientation masks.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{  
    return UIInterfaceOrientationPortrait;
}

你有没有想过?