Openurl焕然一新,无法开放

时间:2013-10-18 09:52:16

标签: ios refresh openurl

我有一个带有3个Container视图的视图,其中两个是picker,最后一个是2个按钮。其中一个按钮打开一个URL,由两个选择器创建,另一个刷新链接。 如果两个选择器都返回(null),则链接起作用。如果其中一个选择器返回一个值,并且单击了刷新按钮,则链接将不再起作用。

    - (void)viewDidLoad
 {
[super viewDidLoad];
// Do any additional setup after loading the view.

[_button_amazon_link setTitle:@"amazon.de" forState:UIControlStateNormal];
[_button_ifixit_link setTitle:@"ifixit.com" forState:UIControlStateNormal];

[self refreshview];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

-(void) refreshview{
AppDelegate *appdelegatestrings = (AppDelegate *) [[UIApplication sharedApplication] delegate];

appdelegatestrings.link_amazon = [NSString stringWithFormat:@"http://www.amazon.com/s/field-keywords=%@+%@", appdelegatestrings.model, appdelegatestrings.dead_thing];

appdelegatestrings.link_ifixit = [NSString stringWithFormat:@"http://www.ifixit.com/Device/%@/%@", appdelegatestrings.model, appdelegatestrings.dead_thing];
link_ifixit_ready = appdelegatestrings.link_ifixit;
link_amazon_ready = appdelegatestrings.link_amazon;

}
-(void) openurl : (NSString *)urlstring
{
NSLog(urlstring);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlstring]];
}
- (IBAction)button_amazon_link_clicked:(id)sender {
[self openurl:link_amazon_ready];

}
- (IBAction)button_ifixit_link_clicked:(id)sender {
[self openurl:link_ifixit_ready];
}

- (IBAction)button_refresh:(id)sender {
[self refreshview];
}

1 个答案:

答案 0 :(得分:0)

   -(IBAction)btn_press:(id)sender{
        [[UIApplication sharedApplication] openURL:[NSURL 
URLWithString:@"http://www.ifixit.com/Device/iPhone"]];
    }

这对我有用!!!

相关问题