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.
How can SFSafariViewController be setup as the Detail Controller for UISplitViewController?
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 need more help, don't hesitate. My solution works, I'm using it at the moment :) –
Adventitia
Is there anyway to hide the done button in that case? or replace it with
displayModeButtonItem
? –
Ifni @Ifni have you found a way to hide the done button - or better yet, as you said, replace it with displayModeButtonItem? –
Patmore
@Patmore unfortunately no. I don’t remember the workaround we came up with and don’t have the code anymore –
Ifni
© 2022 - 2024 — McMap. All rights reserved.