【发布时间】:2013-10-26 04:24:36
【问题描述】:
我的应用中有两个完全包含 URL 的标签:
-(void)openURLA{
NSString *url = @"http://urla.com";
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:url]];
}
-(void)openURLB{
NSString *url = @"http://urlb.com";
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:url]];
}
这个代码在现有方法中:
UITapGestureRecognizer *gra = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openURLA)];
UITapGestureRecognizer *grb = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openURLB)];
当用户点击这些标签之一时,openURL 方法运行良好,并且 URL 在 safari 中打开。
我想知道如何只创建一个方法来打开 URL 并传递包含 label1.text 或 label2.text 值的参数?
我不能 100% 确定从哪里开始,所以我将不胜感激。
【问题讨论】:
标签: ios methods uitapgesturerecognizer openurl