我使用Interface Builder來佈局我的應用程序。我有一個包含一些文本的UITextView,其中的一部分是我想要點擊的URL(例如啓動瀏覽器)。我已經閱讀了如何做到這一點,並相信我正確地做到了,但是當URL顯示爲藍色/可點擊時,在iPhone模擬器中單擊它不起作用。什麼都沒發生。無法在UITextView中使URL可點擊
我的控制器:
@interface FirstViewController : UIViewController <UISearchBarDelegate>
@property (nonatomic, retain) IBOutlet UITextView *review;
@end
我在執行我@synthesize review;
(和我能操縱視圖的文本,所以不覺得這是個問題)。
在IB我有:
..then後,當我去設置文本(並試圖讓網址在視圖中點擊)我做的:
self.review.text = content;
// My understanding is that this makes URLs clickable...
self.review.dataDetectorTypes = UIDataDetectorTypeLink;
...其顯示如下:
...看起來真的很想工作,但是當點擊URL時什麼也沒有發生。我錯過了什麼?
--UPDATE--
試圖響應迪克西特帕特爾的答案添加self.review.editable = NO;
,但它並沒有解決這個問題:
self.review.text = content;
// My understanding is that this makes URLs clickable...
self.review.editable = NO;
self.review.dataDetectorTypes = UIDataDetectorTypeLink;
Downvoted huh?想知道爲什麼。 – Madbreaks