Monday, March 18, 2013

How to display a web page inside a form


  1. Open the story board.
  2. Drag the Web View control from the right panel to the story board.
  3. Open ViewController.h file and add the following code in the @interface section:

    @property (weaknonatomicIBOutlet UIWebView *webBrowser;
  4. Open ViewController.m file and add the following code in the @implementation section:

    @synthesize webBrowser;
  5. In the ViewController.m file, add the following code in the viewDidLoad function:

        NSString *fullURL = @"http://www.google.com";
        NSURL *url = [NSURL URLWithString:fullURL];
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
        [webBrowser loadRequest:requestObj];
  6. Open the story board.
  7. Right click-drag from the yellow view controller icon and drop it onto the Web View control.

  8. A popup will appear with several choices, select webBrowser.
  9. Done.

No comments:

Post a Comment