Search code examples
iosuiviewcontrollerorientationmpmovieplayercontroller

How to Add UIViewController from UVIew with orientation management


I'm creating my custom MPMoviePlayer.

For full screen management, the MPMoviePlayerController behaves this way :

- (void)setFullscreen:(BOOL)fullscreen animated:(BOOL)animated;

I would like to do the same, but with an UIViewController added over all UIView. But when using a UIViewController, the orientation is not managed

My currently code :

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[appDelegate window] addSubview:myViewController.view];

I'd like to manage the orientation using an UIViewController.

Thanks for any help


Solution

  • Yes I Can !

    My ViewController "myViewController" is added over all views with orientation management :

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UIViewController *rootViewController = appDelegate.window.rootViewController;
    [rootViewController presentViewController:myViewController animated:NO completion:nil];