在程序中檢測數字和鏈接
在iPhone 3.0後就支持UIDataDetectorTypes來檢測數字和鏈接。
UIDataDetectorTypePhoneNumber
UIDataDetectorTypeLink
UIDataDetectorTypeNone
UIDataDetectorTypeAll
通過設置dataDetectorTypes屬性就可以實現功能
- (void)viewDidLoad {
- self.textView.dataDetectorTypes = UIDataDetectorTypeAll;
- }
同時你也可以通過Interface Builder來設置屬性。
參考: