Working with UIWebView – loading contents in different ways

This post is going to illustrate different ways of loading contents in UIWebView.

Illustration also includes the steps of creating project as well. For existing projects, skip first 3 steps.

Step 1) Create the new project and select the single view application project template.

Create Project - SingleViewProject

Step 2) Set the application name & save it.

Project name - XCode

Step 3) Declare variable of “UIWebView” into .h file & give a connection .xib file. Don’t forget to set delegate of webView to the “Files Owner” (Here I have an instance of UIWebView within UIWindow, you might need to have at different place.)

Now, There are different way of loading contents in webView.

1) Contents from specific URL.

2) Contents using a HTML string.

3) Contents from web-page stored locally within application.

Option 1) If you notice, following statements load specific webpage from a URL.


UIWebView using URL

Option 2) Loading contents using HTML String.


UIWebView using HTML String

Option 3) Loading contents from a web-page stored locally.

For option-3, I have added sample.html file within my project. Similarly one can also load any web-page locally.


UIWebView loading from local file

step 7) Grab the sample code from here.

One thought on “Working with UIWebView – loading contents in different ways

Leave a Reply

Your email address will not be published. Required fields are marked *