How to present MPMoviePlayerViewController from a UITabBarController?

风格不统一 提交于 2019-12-01 21:17:08

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!