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打开网址的更多相关文章

  1. AJ学IOS(45)之常用的小功能比如打电话、打开网址、发邮件、发短信打开其他应用。

    AJ分享,必须精品 简介 iOS中的很多小功能都是非常简单的,几行代码就搞定了,比如打电话.打开网址.发邮件.发短信.打开其他应用等. 打电话 方法1 最简单最直接的方式:直接跳到拨号界面 NSURL ...

  2. python+selenium调用chrome打开网址获取内容

    目录 1,安装selenium和配置chromedriver 2,调用chromedriver打开网页获取网页内容 3,模拟登陆百度云 附录(webdriver版本兼容列表) 通过selenium库, ...

  3. c# 调用浏览器打开网址并全屏

    关键性参数 Google Chrome浏览器 Process process = Process.Start("chrome.exe", " --kiosk " ...

  4. IE11,Chrome65,Firefox58 的webdriver驱动下载,调用浏览器打开网址

    一.环境及需求 1.1环境 Windows10 + Python 3.6.4 + selenium 3.141 1.2需求 工作需要实现一个网页自动登录的操作,决定使用selenium+python实 ...

  5. C# 调用浏览器打开网址

    private void button1_Click(object sender, EventArgs e) { //调用系统默认的浏览器 System.Diagnostics.Process.Sta ...

  6. [WPF]c#调用默认浏览器打开网址

    //调用系统默认的浏览器 System.Diagnostics.Process.Start("http://www.zhaokeli.com");

  7. cocos2dx调用浏览器打开网址

    安卓端cocos2dx/platform/android路径下CCApplication.h: virtual void openURL(const char* pszUrl); CCApplicat ...

  8. Android调用浏览器打开网址遇到的问题

    我自己的手机(一加一代,升级了氢OS),然后在点击游戏内一个"隐私政策"-- 需要打开一个网页,然后就crash了.出错的信息如下: 完全是看不出来,然后我单独写了一个demo来测 ...

  9. iOS 第三方应用调用safari

    一,直接调用safari打开url [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www. ...

随机推荐

  1. QString和char字符数组之间的转换(QTextCodec.toUnicode方法,特别注意\0的问题)

    How can I convert a QString to char* and vice versa ?(trolltech) Answer:In order to convert a QStrin ...

  2. ArcGIS学习记录—KMZ KML与SHP文件互相转换

      1.在google earth中绘制边界  工具栏中选择"Add Polygon".随意绘制一个多边形.  右击添加的图层名(左侧)保存位置为,选择保存为kmz或kml文件.  ...

  3. PHP array_chunk() 函数

    今天在CSDN上,看到了一个问题 一维数组 PHP code   array('0'=>'a',1=>'b',2=>'c',3=>'d',4=>'e',5=>'f' ...

  4. Git教程(7)用合并还是变基?

    合并或变基前的样子:分支experiment与master两个分支都产生了提交. 图1. 未合并或变基前的样子 合并 原理: 找到两个分支的最末提交和最近的共同祖先,在执行git merge时所处的分 ...

  5. 中国海洋大学第四届朗讯杯高级组 Cash Cow(模拟)

    题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2721 题意: 给定n个左标,跟那n个坐标 ...

  6. poj 1611 The Suspects(简单并查集)

    题目:http://poj.org/problem?id=1611 0号是病原,求多少人有可能感染 #include<stdio.h> #include<string.h> # ...

  7. openSession()和getCureentSession()的区别

    openSession():永远是打开一个新的session getCureentSession():如果当前环境有session,则取得原来已经存在的session,如果没有,则创建一个新的sess ...

  8. ,net运行框架

    .NET FrameWork框架 是一套应用程序开发框架,主要目的提供一个开发模型. 主要的两个组件: 公共语言运行时(Common Language Runtime)(CLR): 提供内存管理.线程 ...

  9. [POJ 3370] Halloween treats

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7143   Accepted: 2641 ...

  10. 使用MySQL

    安装MySQL驱动 使用vpn $ pip install mysql-connector-python --allow-external mysql-connector-python import ...