3

hi i guess this is pretty simple and hope it will be answered in a easy manner!

how do i change the url of the uiwebview when a button is touched up inside?

meaning to say i will have a single web view and everytime a button is clicked the URL of the webview

changes and a new page is reloaded

thanks

AlsonToh-SG
  • 145
  • 3
  • 14

1 Answers1

4

As you suggest, it's very easy:

-(void)buttonPressed:(id)sender {
  [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://website.com/"]]];
}

This is all very well documented.

Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152
  • erm currently im am placing nsurl under view didload , will it still work - (void)viewDidLoad { [webWindow addSubview: activityIndicator]; timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES]; NSString *urlAddress = @"http://npshuttlebus.blogspot.com/2010/12/blog-post.html?m=1"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webWindow loadRequest:requestObj]; [super viewDidLoad]; – AlsonToh-SG Dec 29 '10 at 19:03
  • You'll probably need to wait a bit after that. Try putting it in `viewWillAppear:`. – Stephen Darlington Dec 29 '10 at 20:42