Home Tutorial Iphone Examples loadRequest uiwebview

 
 

loadRequest uiwebview
Posted on: April 28, 2010 at 12:00 AM
Advertisement
The example exhibits the use of loadRequest method in UIWebView.

loadRequest uiwebview

The example exhibits the use of loadRequest method in UIWebView.

loadRequest is basically a method that can be used to load any web page over web view in iPhone application. The method can be written as

- (void)loadRequest:(NSURLRequest *)request;

In this example we are loading the home page of Rose India website. Final application will look alike ..

loadRequest example

Create a View based application in xCode and save it. After that define the outlet and property of UIWebView in .h and synthesize it in .m file. Also release it in dealloc method.

for example..

#import <UIKit/UIKit.h>

@interface readDataViewController : UIViewController {
UIWebView* myview;
}
@property(nonatomic, retain)IBOutlet UIWebView* myview;
@end

#import "readDataViewController.h"

@implementation readDataViewController
@synthesize myview;

- (void)dealloc {
[super dealloc];
[myview release];
}

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

@end

Once you done, just open the viewController.xib in Interface builder and drop the UIWebView onto the UIView from the library and connect it with the file owner.

Uncomment the ViewDidLoad method from the implementation file, and paste the given loadRequest method inside it.

- (void)viewDidLoad {
[super viewDidLoad];

[myview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.roseindia.net/"]]];
}

Build the application to test. It will load the requested URL on the Web View.

Download Code

Advertisement

Related Tags for loadRequest uiwebview:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 28, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com