I have a UIWebView that links to a youtube video. When I press to watch the video, it enters full screen mode, but when I press the "DONE" button in the top left corner, then the video leaves fullscreen but then instantly re-enters full screen. I found that if I pause the video before I press "DONE" then it works as expected. Has anyone else run into this problem?
override func viewDidLoad() {
let url = URL.init(string: "https://www.youtube.com/embed/we8o1WPx_c0")
let urlrequest = URLRequest.init(url: url!)
videoWebView.loadRequest(urlrequest)
}
Here's a video of what's happening if it's not clear from my description: https://youtu.be/qSC6VdPANGg
UIWebView has been deprecated. I swapped UIWebView for WKWebView and everything works as expected.
After putting a UIView on the storyboard named videoContainer
I have this:
self.videoWebView = WKWebView(frame: self.videoContainer.bounds)
let url = URL(string: "https://www.youtube.com/embed/we8o1WPx_c0")
videoWebView!.load(URLRequest(url: url!))
self.videoContainer.addSubview(videoWebView!)