2012-03-05 25 views

回答

4

是的,有一個解決方案。您可以使用正則表達式來檢測標籤開始觸摸時特定類型的字符串,然後基於匹配字符串的正則表達式來執行該操作。

所以,如果你想這樣做,你需要繼承UILabel並覆蓋標籤的Touch方法。

希望這可以幫助你。

有一個標籤叫做OHAttributedLabel,它具有類似的功能。這裏是支持ARC的fork

2

你可以使用一個UIButton與按鈕類型爲UIButtonTypeCustom,在按鈕上點擊你可以調用的URL。

UIButton *urlButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
urlButton.frame = CGRectMake(10, 10, 80, 30); 
[urlButton setTitle:@"Click Here" forState:UIControlStateNormal]; 
[urlButton addTarget:self action:@selector(urlButtonClicked) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:urlButton]; 
+1

問題是關於UILabel而不是UIButton。 – 2012-03-05 05:17:44