2010-11-21 9 views

答えて

0

UITextViewでdataDetectorTypesを有効にすると、URL(およびその他の共通リンク)が検出され、デフォルトのアプリケーションに自動的にリンクされます。

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectZero]; 
text.dataDetectorTypes = UIDataDetectorTypeLink; // see below for other options 

はiOS7からhttps://developer.apple.com/library/content/qa/qa1495/_index.html

0

ここでは他のdataDetectorTypesオプションについては、アップルのマニュアルを参照してください、後で今ではUITextViewでリンクを検出することがより容易になります。

UITextView *txtView=[[UITextView alloc]initWithFrame:CGRectMake(0, 10, 320, 500)]; 
txtView.delegate=self; 
txtView.dataDetectorTypes = UIDataDetectorTypeLink; 

このデリゲートメソッドの実装:

- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange{ 

    // do what ever you want 
    return YES; 
} 
関連する問題