0
votes

I have one view holding a list of videos(buttons which can be clicked, each hold a url) which currently bring up a new view which holds the UIWebview, the only problem is I cant pass the url to the webview depending on which button was clicked.

At the moment I just get an empty UIWebview.

How can the url string be passed to the webview so it can load the correct url for each button?

Regards

1

1 Answers

1
votes
NSURL *videoURL = [NSURL URLWithString:@"http://..."];
[webView loadRequest:[NSURLRequest requestWithURL:videoURL]];

UPDATE:

In response to comment #3, here's what you can do:

  1. This goes without saying, but keep a reference to the UIWebView instance in Browser
  2. Add an NSString or NSURL @property to Browser
  3. Pass the URL to the Browser instance right after init
  4. In viewDidLoad:, call loadRequest:

So your code might look like this:

- (void)buttonClicked {
    Browser *browser = [[Browser alloc] initWithNibName:nil bundle:nil];
    browser.URL = [NSURL URLWithString:@"http..."];
    [self presentModalViewController:browser animated:YES];
    [browser release];
}

and in Browser's viewDidLoad:

- (void)viewDidLoad {
    [super viewDidLoad];
    [webView loadRequest:[NSURLRequest requestWithURL:URL]];
}