How to present MPMoviePlayerViewController from a UITabBarController?

前端 未结 1 373
青春惊慌失措
青春惊慌失措 2021-01-21 05:18

I have a view controller that\'s been added to a UITabBarController. In this view controller I have a button that opens up a movie using MPMoviePlayerViewCont

相关标签:
1条回答
  • 2021-01-21 05:42

    Figured it out. I guess things get wonky because MPMoviePlayerViewController has a method added as a category to UIViewController called presentMoviePlayerViewControllerAnimated:. Normally you would call it like this in your UIViewController:

    [self presentMoviePlayerViewControllerAnimated:mp];
    

    But in this case, if you've added your view controller to a UITabBarController stack, self is your view controller within the tab bar controller, and I guess this makes things screwy. The fix is to call presentMoviePlayerViewControllerAnimated: with the parent view controller, which in my case, was another UIViewController that was housing UITabBarController. I simply referenced the parent view and added it to my view controller's init method, then called something like [parentController presentMoviePlayerViewControllerAnimated:mp].

    Whew. Hope that helps someone.

    0 讨论(0)
提交回复
热议问题