It seems from the documentation and all examples that I have found that a SFSafariViewController must be programmatically instantiated with a specific URL as a setup parameter. Is it possible to use a SFSafariViewController as the Detail Controller for a UISplitViewController? The only way I can think of to do this is to setup a segue in the storyboard, but in that case the SFSafariViewController would not have the URL it needs to display its contents. Any advice on how to accomplish this, programmatically if possible, would be appreciated.
It's possible ! I've searched for a long time and I found a solution. I'm doing it in my main view controller, a Table View Controller. If I select a cell of my Table View, a SafariViewController is opened in the detail view.
let safariViewController = SFSafariViewController(URL: NSURL(String: "http://google.com"))
self.showDetailViewController(safariViewController, sender: nil)
Result : Safari View Controller Detail
It comes with some problems.
You should use iOS 9.1 or more to avoid this UI bug : UI Bug Safari View Controller
You should hide the navigation bar if you want to see the standard safari view controller bar (with URL, ...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With