New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Viewing pages in Safari

From: iOS SDK and SQLite: Building Data-Driven Apps

Video: Viewing pages in Safari

Now, we have a working webView and we'd like to be able to pass pages off to Safari as a full-featured mobile web browser. Let's see how we do that. We'll navigate here to Chapter 6 of our exercise files, and we're going to make a working copy of our webView-02. I'm using the -done version. You can use the version that you created if you've been following along with the exercises. I'm going to rename that to -03 and open it up in Xcode by double-clicking on the Xcode project file here in the project folder.

Viewing pages in Safari

Now, we have a working webView and we'd like to be able to pass pages off to Safari as a full-featured mobile web browser. Let's see how we do that. We'll navigate here to Chapter 6 of our exercise files, and we're going to make a working copy of our webView-02. I'm using the -done version. You can use the version that you created if you've been following along with the exercises. I'm going to rename that to -03 and open it up in Xcode by double-clicking on the Xcode project file here in the project folder.

So, I'm going to minimize that and come back up here to our actionButton method. And this our actionButton that gets called whenever we press that button. It has an NSLog right now. So, if I run this in the iPhone Simulator, and I'll bring up a page here, and you'll notice when I press this button, instead of launching Safari, it just displays this log message that says the URL that's been called.

And so I'll come back here in Xcode. I'm going to press Command+. to stop the simulator. I'm going to minimize that down there, and we're just going to replace this line with the line of code that will actually call Safari. And that looks like this. It's a method call on an object. So, I'm going to type in UIApplication.sharedApplication and openURL. And for the URL itself, I'm going to call self.webView.request.URL.

And so the webView itself keeps a copy of the URL for the current request that is being displayed. And so that gives us the URL. This openURL method is called on UIApplication.sharedApplication. So, UIApplication is a centralized point of control for all iOS applications. It provides access to system resources. sharedApplication is a property that gives the application instance, the individual application that you are using. So, you call methods on the sharedApplication property within UIApplication.

openURL is the system entry point for opening a URL resource with the associated application. Our HTTP or HTTPS applications will open in Safari. So, let's go ahead and run this in the Simulator, pressing Command+S to save and clicking on the run button here. And now, when I bring this web page up and I press this button here, it will load up Safari with that URL.

So now, we have a complete working webView. It's really a very simple task. Cocoa Touch provides a simple delegate-based webView that's powerful, flexible, and easy to implement, and it works very well.

Show transcript

This video is part of

Image for iOS SDK and SQLite: Building Data-Driven Apps
iOS SDK and SQLite: Building Data-Driven Apps

41 video lessons · 6326 viewers

Bill Weinman
Author

 
Expand all | Collapse all
  1. 8m 29s
    1. Welcome
      57s
    2. Exercise files
      2m 17s
    3. Course overview
      3m 4s
    4. Application overview
      2m 11s
  2. 14m 49s
    1. Prototyping in a testbed
      1m 27s
    2. Building the view controller
      3m 45s
    3. Coding the testbed
      7m 56s
    4. Using the testbed
      1m 41s
  3. 37m 49s
    1. Understanding SQLite in iOS
      1m 41s
    2. Creating an Objective-C interface for SQLite
      9m 57s
    3. Testing the BWDB interface in the sandbox
      7m 1s
    4. Designing a database schema
      8m 7s
    5. Supporting the application with a specific interface
      7m 7s
    6. Using C pointers with automatic reference counting (ARC)
      3m 56s
  4. 21m 18s
    1. Understanding the table view
      1m 33s
    2. Creating the view controller
      6m 39s
    3. Reading from the database
      13m 6s
  5. 33m 50s
    1. Understanding the parsing process
      1m 57s
    2. Creating the item view controller
      12m 25s
    3. Reading data from the internet
      5m 30s
    4. Parsing the feed with NSXMLParser
      8m 2s
    5. Updating the item view with the feed items
      5m 56s
  6. 40m 14s
    1. Understanding the modal view
      1m 47s
    2. Constructing the view controller
      15m 5s
    3. Finding a feed link in a web page
      8m 55s
    4. Parsing the feed with NSXMLParser
      5m 4s
    5. Delegating back to the parent view
      6m 11s
    6. Deleting feeds
      3m 12s
  7. 21m 5s
    1. Creating the web view class
      12m 33s
    2. Coding the web view
      5m 25s
    3. Viewing pages in Safari
      3m 7s
  8. 14m 3s
    1. Understanding the iOS preferences system
      1m 23s
    2. Creating the preferences plist in Xcode
      7m 20s
    3. Reading preferences in your application
      5m 20s
  9. 6m 15s
    1. Adding pull-to-refresh functionality
      2m 34s
    2. Implementing the pull-to-refresh gesture for iOS 6
      3m 41s
  10. 27m 1s
    1. Understanding split view
      1m 4s
    2. Coding the table views
      11m 24s
    3. Implementing the iPad detail view
      6m 35s
    4. Implementing the iPad modal view
      7m 58s
  11. 35s
    1. Goodbye
      35s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.