WebView application in iPad

In this application we will displayed the WebView in the Screen. Let see how it will be worked in the iPad.

In this application we will displayed the WebView in the Screen. Let see how it will be worked in the iPad.

Step 1: Create a new Xcode project using the View base application template. Give the application name “WebiPad”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand classes and notice Interface Builder created the WebiPadViewController class for you. Expand Resources and notice the template generated a separate nib, WebiPadViewController.xib, for the “WebiPad”.

Step 4: Open the ViewController.h file , in this we have added UIWebView for displaying the webpage. So make the following changes in the file.

#import <UIKit/UIKit.h>
  @interface WebiPadViewController : UIViewController {
  IBOutlet UIWebView *webDisplayiPad;
}
@property(nonatomic,retain) UIWebView *webDisplayiPad;

Step 5: Double click the WebiPadViewController.xib and open it to the Interface Builder. Open the View window and drag the Web View from the library and place it to the view window. Connect File’s Owner icon to the View icon and select view. Next drag File’s Owner icon to the UIWebView and select the webDisplayiPad(See the figure 1). Now it all done, save it close it and go back to the Xcode.

Figure 1: Connection between file owner to the WebView

Step 6: Open the ViewController.m file make the following changes in the file.

- (void)viewDidLoad {
   NSString *urlAddress = @"http://www.google.com";
 
//Create a URL object.
  NSURL *url = [NSURL URLWithString:urlAddress];

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

//Load the request in the UIWebView.
 [webDisplayiPad loadRequest:requestObj];

 [super viewDidLoad];
}

Step 7: Now compile and run the application in the Simulator.

Figure 2: Output of the application

You can downloaded SourceCode from here WebiPad

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic, and free programming tips and tricks and source code            snippets.

6 Responses to “WebView application in iPad”

  1. Graham says:

    Gee I had been having a hard time to find a webview tutorial that works, or at least one that I could get to work. Thank you Friend…
    My first app is running

  2. iCiccio says:

    Hello,
    I have to make an app for iPad, wings are a beginner, I would like to create a slitview with ertain lines containing the sections of my site, however it should display a link in detailview, so it must be a WebView.

    how can I indicate for each line to display a web address?

    thanks

  3. thirupathi says:

    Excellent Tutorial…Really you made my job simple…………….awesome

Leave a Reply

Security Code:

learn iphone programming

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Our Mobile Training Courses

EDUmobile.ORG offers the following 4 Mobile Training Courses. Our iPhone Training Course is very popular, with over 200 developers in training.

learn iphone programming
© 2010 EDUmobile.ORG