Sometimes you'll want to open a full browser app from your application. In those cases, you can open a URL using the system's default browser- Safari. See how it works in this video.
- [Instructor] Sometimes you may want to open up a URL…in a full web browser.…Or, open up a Facetime conversation or an email.…Let's take a look at how to do that.…Here we have our method ShowWebContent.…Here we're creating a URL, making sure that it's non-nil.…And inside of this if block, we're going to open up Safari…by calling UIApplication.shared.open.…And here we pass in a URL and some other parameters.…
I'll just press return to have X code complete that for me.…And the URL I wan to open is just going to be URL,…all lower case.…I'll Tab over to options, this allows you to define…a dictionary for options for your opening URL.…We'll talk about that just a little bit later on.…Here, I'm going to set just an empty dictionary, so [:]…and then I'll Tab over to the third parameter,…which is the completion handler.…This is a Boolean function that's triggered…when Safari opens up.…
And it tells you whether or not the URL…loaded successfully.…So, of course, the value of true means…it loaded successfully and a value of false…
- Alert controllers and actions
- Sliders, progress bars, and switches
- Creating UI elements with code
- Displaying web content with Safari view controllers and WKWebView
- Creating collection view controllers
- Creating tabbed apps
- Publishing your app with App Store Connect
Skill Level Beginner
1. Master Views
2. Display Web Content
3. Collection Views
4. Multiview Templates
Customize a table view cell4m 18s
5. Publish an App
Next steps3m 28s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.