让UILabel具有链接功能,点击后调用safari打开网址
2015-01-24 20:23
363 查看
UILabel *labelGovUrl = [[UILabel
alloc]
initWithFrame:CGRectMake(73.0,
330.0,
180.0,
40.0)];
labelGovUrl.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
labelGovUrl.text =
@"appStore";
labelGovUrl.backgroundColor = [UIColor
clearColor];
labelGovUrl.textColor = [UIColor
blackColor];
labelGovUrl.font = [UIFont
fontWithName:@"Helvetica-Bold"
size:14];
labelGovUrl.userInteractionEnabled =
YES;
labelGovUrl.tag =
k_NNGOV_WEBSITE_LABEL_URL;
UITapGestureRecognizer *tapGesture = [[[UITapGestureRecognizer
alloc]
initWithTarget:self
action:@selector(openURL:)]
autorelease];
[labelGovUrl
addGestureRecognizer:tapGesture];
[self.window
addSubview:labelGovUrl];
[labelGovUrl
release];
-(void)openURL:(UITapGestureRecognizer
*)gesture
{
NSInteger tag = gesture.view.tag;
NSString *url =
nil;
if (tag ==
k_NNWEIBO_LABEL_URL)
{
url = @"http://t.qq.com/yourgame/";
}
if (tag ==
k_NNGOV_WEBSITE_LABEL_URL)
{
url = @"http://www.zjnn.cn/";
}
[[UIApplication
sharedApplication]
openURL:[NSURL
URLWithString:url]];
}
相关文章推荐
- 让UILabel具有链接功能,点击后调用safari打开网址
- iOS 点击UIWebView中链接调用Safari打开链接
- iphone之点击UIWebView中链接调用Safari打开目标链接
- 点击UIWebView中链接调用Safari打开目标链接
- iphone之点击UIWebView中链接调用Safari打开目标链接
- UIWebView中链接调用Safari打开目标链接 点击cell里面的一个按钮如何确定按钮所在的cell的行
- iOS开发中,调用打电话,发短信,打开网址等手机基础功能
- 如何在WebView中点击链接,使用自己的activity打开,不调用系统自带的浏览器
- C#中调用Flash按钮,点击按钮可打开相应的功能
- Android编程实现点击链接打开APP功能示例
- 调用Safari打开UIWebView中链接的代码
- 点击网页中PDF链接时,打开PDF文档不再是直接IE查看,而是提示下载保存
- 打开Safari的Javascript调试功能
- 解决WebBrowser中打开链接调用IE窗口问题
- 一个链接按两种方式打开两个网址的方法
- 一个链接按两种方式打开两个网址的方法
- 调用浏览器打开网址
- HTML: 点击链接时在新窗口打开
- Safari设置默认tab打开新链接
- JSP 点击链接后下载文件(相当于右键另存)功能