在iOS程序中檢測數字和鏈接

在程序中檢測數字和鏈接

在iPhone 3.0後就支持UIDataDetectorTypes來檢測數字和鏈接。

UIDataDetectorTypePhoneNumber

UIDataDetectorTypeLink

UIDataDetectorTypeNone

UIDataDetectorTypeAll

通過設置dataDetectorTypes屬性就可以實現功能

- (void)viewDidLoad {

- self.textView.dataDetectorTypes = UIDataDetectorTypeAll;

- }

clip_p_w_picpath002

同時你也可以通過Interface Builder來設置屬性。

clip_p_w_picpath004

 

參考:

https://developer.apple.com/devcenter/ios/index.action

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章