Reputation: 443
i make an app that shows Bollywood News For that i make UITableView
and each cell contain Nes and each cell was selected then i want to redirect to UIWebView
with its link. So how it possible to pass a URL
to UIWebView
.
Here My Code for didSelectRowAtIndexPath
:
My Code here :
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *dict = [self.imagesa objectAtIndex:indexPath.section];
NSString *link=[dict valueForKey:@"link"];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:link]];
}
Here All Data is Come From JSON
Data Here dictionary key Value is "link" and each link is Contain each cells relative URLLink i want to open that link in to UIWebView
.i make for that a UIWebView
Controller but not know how to pass a link to UIWebView
How it is Possible Please Give me solution.
Upvotes: 0
Views: 826
Reputation: 27072
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *dict = [self.imagesa objectAtIndex:indexPath.section];
NSString *link=[dict valueForKey:@"link"];
//Create a URL object.
NSURL *url = [NSURL URLWithString:link];
WebViewController *webView=[[WebViewController alloc]initWithNibName:@"WebViewController" bundle:nil];
webview.url = url; // pass URL to webview controller
[self presentViewController:webView animated:YES completion:nil];
}
Now in WebViewController.m
- (void) viewDidAppear:(BOOL) animated {
//URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
Upvotes: 2