2013-07-21 53 views
0

合作我有iOS應用,並在一個字符串,我的文字像這樣轉換HTML鏈接到iOS應用

文字文字文字文字文字HTTP鏈接:// mylink.com文本文本TEXT TEXT TEXT

是否有可能識別該鏈接並使其工作?

感謝

回答

0

在UITextView的,看看dataDetectorTypes

UITextView *test = [[UITextView alloc] initWithFrame:CGRectMake(0.0f, 150.0f, 320.0f, 200.0f)]; 
     test.text = @"Some text http://www.yahoo.com/ more text"; 
     test.editable = NO; 
     test.dataDetectorTypes = UIDataDetectorTypeLink; 
     [self addSubview:test]; 

在字符串中的鏈接將變成藍色,並強調,挖的時候,它會在Safari啓動。您可以更多地檢測到:

test.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber;