UIWebView class allows you
to embed web content inside your application. This class is
the simplest but least flexible way of getting network content into your
UIWebView is best used
to display content. If you want to manipulate the content
programmatically, you should skip ahead a couple of sections and look at
the discussion of the
class. However, there are a few tricks you can play to retrieve the
displayed content from the
once it has been downloaded, and I’ll talk about them later in the
There are a number of cases where you might want to load a URL and
display a web page, but keep users inside your application rather than
closing it and opening Safari. If this is what you need to do, you
should be using a
So, let’s build some code that you’ll be able to reuse in your own
applications later. The specification for this code is a view controller
that we can display modally, which will display a
UIWebView with a specified web page, and can
then be dismissed, returning us to our application.
I’m going to prototype the code here, hanging it off a simple view with a button that will pull up the modal view. However, the view controller class is reusable without modification; just drag and drop the code out of this project and into another. This is also a good exercise in writing reusable code.
Open Xcode and start a new project, choose a view-based iPhone OS ...