ask123
ask123

Reputation: 217

Pass website URL from Tableview to webview

HI I have created a NSMutablArray and add 8 objects to it in the RootViewController. I am displaying the array in the tableview. Whenever i click on the cell with a certain name, i want to pass a URL to the webview which is currently part of anothe DetailViewController.

In that detail view controller,the respective web page has to be displayed.


Added from a comment

I wrote this code in didselect row at indexpath

CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0); 
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame]; 
[webView setBackgroundColor:[UIColor whiteColor]]; 
NSString *urlAddress = @"h.com";; 
NSURL *url = [NSURL URLWithString:urlAddress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[webView loadRequest:requestObj]; 
[self.view addSubview:webView]; 
[webView release]; 

My array name is listofitems, so how can i directly call my array into the url address?

Upvotes: 0

Views: 804

Answers (1)

Swastik
Swastik

Reputation: 2425

DetailsViewController *viewController = [[DetailsViewController alloc] 
  initWithNibName:@"DetailsViewController" bundle:nil];

[viewController setUrl:actualUrl];

where actualUrl is the value in your rootViewController & create another variable url in detailViewController

Upvotes: 1

Related Questions