0

I have a parentViewController in potrait mode and I want to add childViewController(which is a subclass of MPMoviePlaycontroller) to it in a landscape mode this is the code I am using:

In ParentViewController.m

-(IBAction)playMovie
{
     ChildViewController *childViewController = [[ChildViewController alloc] initWithContentURL:url];

    [self.navigationController.view addSubview:childViewController.view];
    childViewController.view.alpha = 0.0;
    [childViewController beginAppearanceTransition:YES animated:YES];
    [UIView
     animateWithDuration:0.3
     delay:0.0
     options:UIViewAnimationOptionCurveEaseOut
     animations:^(void){
         childViewController.view.alpha = 1.0;
     }
     completion:^(BOOL finished) {
         [childViewController endAppearanceTransition];
         [childViewController didMoveToParentViewController:self.navigationController];
     }
     ];

}

In ChildViewController.m

-(BOOL)shouldAutorotate {
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

The problem is ChildViewController is still being displayed in portrait mode.

hariszaman
  • 8,202
  • 2
  • 40
  • 59
  • check out my answer here similar to you want may helps you http://stackoverflow.com/questions/25116967/youtube-video-directly-not-playing-to-landscape-mode-ios-7/25119235#25119235 – Mohit Aug 25 '14 at 07:28
  • tried it, not working – hariszaman Aug 25 '14 at 07:34

1 Answers1

0

ChildViewController *childViewController = [[ChildViewController alloc] initWithContentURL:url];

[self.navigationController addChildViewController:childViewController];

[self.navigationController.view addSubview:childViewController.view];

The child view controller should be added to its parent view controller first before its view being accessed.

meim
  • 740
  • 4
  • 7