2013-02-18 95 views
0

我想创建超链接,如在html <a href="...">text</a>中。是否有可能超链接Xcode中的标签?带标签的Xcode链接

+0

不开箱即用。你需要一个UITextField,但是如果你禁止用户交互,它几乎是一样的。这有帮助吗? – katzenhut 2013-02-18 23:02:42

+0

更具体些。你需要标签的一部分超链接还是整个标签? – vqdave 2013-02-18 23:02:50

+0

我的意思是一个UITextView。下面是文档链接:[link](http://developer.apple.com/library/ios/#documentation/uikit/reference/uitextview_class/Reference/UITextView.html) – katzenhut 2013-02-18 23:10:35

回答

-1

只是tapGestureRecognizer添加到标签

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTapped:)]; 
    tapGesture.numberOfTapsRequired = 1; 
    self.theLabel.userInteractionEnabled = YES;//Since by default, UILabel is not interaction enabled 
    [self.theLabel addGestureRecognizer:tapGesture]; 


    //Some where in the code 
    -(void)labelTapped:(UIGestureRecognizer *)sender 
    { 
     //Do some stuff 
    } 
+1

为什么在世界上你会使用手势识别器..? – vqdave 2013-02-18 23:41:38

+3

@vectorquake如果你提供了更好的建议,你的评论会更有用。除非你能解释为什么这是一个坏主意或提供一个更好的主意,否则不要放弃某人建议的解决方案。谢谢。 – rmaddy 2013-02-19 01:25:07

+0

我会尝试一下,thx很多:-) – stepik21 2013-02-19 18:47:13

0

我建议使用Round Rect Button然后设置背景图像是是颜色作为您的视图的背景色相同的图像。