Create UIWebView in iPhone using Objectiv-C

A UIWebView class is used to embed web content in your application.


A sample code describes the implementation of UIWebView in detail.


CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0);
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setBackgroundColor:[UIColor whiteColor]];
NSString *urlAddress = @"http://--Any Web Site Address--"; // Fill the string with Website address
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[self addSubview:webView];
[webView release];



NSURL class is used to create an object which will hold the URL information.


NSURLRequest is used to create a request to the URL.


Method loadRequest of UIWebView is used to load the request in the UIWebView.

Comments

Popular posts from this blog

Integrating ZXing QR Code reader in iPhone / iOS applications

Multiple line of text in UIPickerView

Custom Message extension using Messages SDK - iMessage App store