UIWebView modal YouTube player “Done” button action

烈酒焚心 提交于 2019-11-30 09:04:36

I'm not sure but it seems that after the "done" button is pressed and the Player is closed the control returns to the root view controller, in your case that's your first screen.

For exaple in my application I have an UITabBarController as my rootViewController, in my AppDelegate I have something like this:

self.window.rootViewController = self.myTabBarController;

So that's the reason why my tabBarController (my first screen) always was presented after pressing the "done" button.

I solved this setting my Modal View as my rootViewController after presenting it.

Try this after presenting your modal view:

MyAppDelegate *appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication] delegate];
[self presentModalViewController: myModalViewController animated: YES];
[self.appDelegate.window setRootViewController: myModalViewController];

NOTE: After dismissing the modal view you must restore the root view controller doing

In my case:

self.appDelegate.rootViewController = self.appDelegate.myTabBarController;

Hope it helps

Not an exact solution but a kind of patch can may be help you out.

Take a global flag (may be in ApplicationDelegate) and set it to true when ever you tap on Done button on the youtube page. And in the very first controller viewWillAppear check if the flag is TRUE then present the second controller and turn the flag FALSE again.

Hope it helps.

The answer re: "I solved this setting my Modal View as my rootViewController after presenting it." is the correct approach. If you call youtube from a modally presented view controller it will return to the original controller which presented the modal one. If you then try to re-present the correct controller using flags it gets really messy and there can be timing issues. Izaakcito's method works properly.

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