代码:
在 UITableViewCell 中
1
2
3
4
5
6
7
8
9
10
11
|
override
func
gestureRecognizer
(
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceiveTouch
touch
:
UITouch
) -
>
Bool
{
if
let
label
=
touch
.
view
as
?
TTTAttributedLabel
,
let
link
=
label
.
linkAtPoint
(
touch
.
locationInView
(
label
))?.
result
{
if
let
url
=
link
.
URL
where
(
link
.
numberOfRanges
??
0
)
>
0
{
if
UIApplication
.
sharedApplication
().
canOpenURL
(
url
) {
UIApplication
.
sharedApplication
().
openURL
(
url
)
}
}
return
false
}
return
true
}
|
文章:
https://github.com/TTTAttributedLabel/TTTAttributedLabel/issues/266
本文转自博客园农民伯伯的博客,原文链接:【Swift】UITableViewCell 中 TTTAttributedLabel 超链接无法点击的问题,如需转载请自行联系原博主。