Beginning iPhone dev adding a web view

In this tutorial I will show you how to add a web view to your app.

Click on the .h file you would like to add the web view to. Between the {} add the following.

IBOutlet UIWebView *webView;

Then in your .m file add

- (void)viewDidLoad {

        NSString *urlAddress = @"";

        //Create a URL object.
        NSURL *url = [NSURL URLWithString:urlAddress];

        //URL Requst Object
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

        //Load the request in the UIWebView.
        [webView loadRequest:requestObj];
        webView.delegate = self;

Save both the .h and .m files. Now the last thing you have to do is change your .xib file. Go ahead and double click on it. Now you need to add a web view to the view. So scroll down in the library tell you find the web view.

Now drag it into the .xib file and drop it under view. Then select File’s Owner.

Now you should see something like this.

Make sure that the class is set to what ever you called your .h and .m file, for example I named my file FirstViewController.m.
Then click the tab that is the second from the left, it should look like this.

If you don’t have the web view then go back and save your .m and .h files. If you mouse over the circle next to the web view it should turn into a + sign click and drag the + to the web view on the .xib. The last thing you need to do is find the view and stretch the web view so it takes up the whole screen.

Now save the .xib file and run the project.

This entry was posted in Regular iPhone Apps. Bookmark the permalink.

2 Responses to Beginning iPhone dev adding a web view

  1. Thanks , I’ve recently been searching for information about this subject for a long time and yours
    is the greatest I’ve found out so far. But, what in regards to the bottom line?

    Are you positive concerning the supply?

  2. Thank you so musch , I’ve recently been searching for information about this

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>