I have a uiwebview that plays a youtube video. How can I handle the done button action? Right now, when I tap the done button it changes back to my app main menu (not the menu that was supposed to dismiss to) and it just freezes. Can anyone help me please?
Ps: the menu where the uiwebview is located, was previously presented modally.
@Gdx Wu @lambmj
Thanks for your methods, they work fine. But there is some small problem that after clicking the done button & jumping directly to the presenting view controller, we need to dismiss the presented modal view controller and present it again, which would bring some dither(like flash) between these view controller switches.
Based on this, I highly recommend @IsaacCisneros 's method which would switch seamlessly.
Simply remove UIWebView when it enters full screen; add back UIWebView when it exit full screen. Sample code below assuming a UIViewController with subview of UIWebView, and your UIWebView should have youtube iframe.
This thread is very useful and help me to find the problem!
The answer of lambmj works fine, but I found a better way. In presenting view controller:
Hope this helps!
The YouTube plug-in player is itself a modal view controller. It is returning to its
presentingViewController
when the done button is pressed. ItspresentingViewController
is not your modal view controller but is instead the viewController that called[presentModalViewController:animated:]
to present your modal view controller. Since the original modal view controller is still active, the app behaves badly.To fix the problem,
1) Track whether the modal view controller has been presented but not dismissed.
2) In the
viewDidAppear
method of the presenting view controller, if the modal view controller was presented and not dismissed, dismiss and present it again.For example, in controller that is presenting the modal web view controller: