0
Could you help me make a button with a link to a website? It’s an iPhone app and I’d like you to press a button and open the site in Safari (for example).
0
Could you help me make a button with a link to a website? It’s an iPhone app and I’d like you to press a button and open the site in Safari (for example).
0
The function for this is the openURL
, an example:
@IBAction func WebLink(sender: AnyObject) { if let url = NSURL(string: "http://...") { UIApplication.sharedApplication().openURL(url) } }
I’ve solved thank you (:
If you already solved please edit your question or create an answer telling how you solved the problem.
0
Another approach would be to use the SFSafariViewController
, it opens safari without leaving your app. This greatly improves the usability of the App.
First, in your Viewcontroller, import the SafariServices
. And use the SFSafariViewController
as follows:
if let url = URL(string: "http://...") {
let safariViewController = SFSafariViewController(url: url)
present(safariViewController, animated: true)
}
Browser other questions tagged swift xcode
You are not signed in. Login or sign up in order to post.
how do I do? I did the butao but do not know what to do now
– Bruno Gonçalves
And what do you want to do? What behavior do you expect this button to have? You can [Dit] your question and include more information. By the way, make a tour and better understand how Stackoverflow works, welcome.
– Renan Gomes
I’ve already made my point
– Bruno Gonçalves
You mentioned that you already made the button, could edit your question and include the button code in it?
– Chun
the boot I made was just create a boot nothing else, I did no code
– Bruno Gonçalves
Take a look at this link @Brunogonçalves , E this link also
– Chun
how I create an Ibaction?
– Bruno Gonçalves