Sometimes you 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] Let's say instead…of showing a Safari view controller,…you want to just open up a Safari application.…Maybe you have a reason to get the user out of your app…to give them the freedom to make some choices…about where they go on the web,…and this is how you do that.…So instead of my showWebContent method,…I'm actually going to delete these four lines of code…where we create the SafariViewController,…but I'm going to keep my URL there.…So everything else is going to be pretty much the same,…just we don't create a Safari controller.…
We just tell our application to open this URL.…So we do that by typing UIApplication.shared.…So that grabs our application object.…Then we tell that to open the URL.…So here we pass in the URL.…And we'll have to unwrap it.…And for the options,…you can send a dictionary with string keys,…but we don't have any options for our URL,…so I'm just going to pass in an empty dictionary…just like this.…
And then for the completion handler,…you can handle it if you like,…or you can just pass in nil,…
Instructor Todd Perkins shows how to use pickers, pop-up messages, sliders, switches, and indicators to build a sophisticated app interface, and display HTML content, files, and data with web views. Plus, learn how to dynamically update your layouts using size classes, and get a brief overview of the Apple Human Interface Guidelines.
- Picker views, controllers, sliders, and indicators
- Creating UI elements with code
- Displaying images with image views
- Creating web views to display web content
- Changing fonts, pins, and views with size classes