Hi guys, I am a newbie at iPhone development and have a question, which may end up helping understand this concept in general.
Basically, I have UIViewController which loads up a view with a bunch of stuff. Now I want when a user clicks on a button, to load up a different view, which happens to be a webView. Now, I want the weview to load up a different url depending on which button was pressed in the original view.
how do i go about doing this? Basically in my head I thought i could load and swap the views when the button is pressed, like so:
In
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedLink = [valuesForSection objectAtIndex:row];
NSString *urlAddress = @"http://www.google.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
[self.view removeFromSuperview];
[self.view insertSubview:webView atIndex:0];
}
Is this the right way of doing it? Or how do i go about doing this?