Press a Button and open a URL in another ViewController
Posted
by
Dennis Borup Jakobsen
on Stack Overflow
See other posts from Stack Overflow
or by Dennis Borup Jakobsen
Published on 2012-11-03T10:25:00Z
Indexed on
2012/11/03
11:00 UTC
Read the original article
Hit count: 265
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
© Stack Overflow or respective owner