Press a Button and open a URL in another ViewController
- by Dennis Borup Jakobsen
I am trying to learn Xcode by making a simple app.
But I been looking on the net for hours (days) and I cant figure it out how I make a button that open a UIWebView in another ViewController :S
first let me show you some code that I have ready:
I have a few Buttons om my main Storyboard that each are title some country codes like UK, CA and DK.
When I press one of those Buttons I have an IBAction like this:
- (IBAction)ButtonPressed:(UIButton *)sender {
// Google button pressed
NSURL* allURLS;
if([sender.titleLabel.text isEqualToString:@"DK"]) {
// Create URL obj
allURLS = [NSURL URLWithString:@"http://google.dk"];
}else if([sender.titleLabel.text isEqualToString:@"US"])
{
allURLS = [NSURL URLWithString:@"http://google.com"];
}else if([sender.titleLabel.text isEqualToString:@"CA"])
{
allURLS = [NSURL URLWithString:@"http://google.ca"];
}
NSURLRequest* req = [NSURLRequest requestWithURL:allURLS];
[myWebView loadRequest:req];
}
How do I make this open UIWebview on my other Viewcontroller named myWebView?
please help a lost man :D