tags:

views:

16

answers:

1

hey, I am new to objective-c so i do not know how to create webview control.I want to display any web page in web view so how can i do this. thanx for help in advance....

A: 

First create a view based application, in the View, add a UIWebView, and in the .plist add a Application Uses Wi-Fi key, and set it YES. In the ViewController class' .h file make the code look like this:

#import <UIKit/UIKit.h>

@interface ClassNameHere : UIViewController {

    UIWebView *webView;

}

@property (nonatomic, retain) IBOutlet UIWebView *webView;

@end

In the .m file, add this code:

@synthesize webView;

- (void)viewDidLoad {
    NSString *urlString = @"http://www.google.com";

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

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

    //Load the request in the UIWebView.
    [webView loadRequest:webRequest];
}

Finally, in your nib file, connect the webView outlet to the UIWebView. When you compile, it should open Google.

NSArray