theTweet = [[[UITextView alloc] initWithFrame:CGRectMake(65, 10, 225, 65)] autorelease];
theTweet.text = [[tweets objectAtIndex:index] objectForKey:@"text"];
theTweet.dataDetectorTypes = UIDataDetectorTypeLink;
[tweetView addSubview:theTweet];
[[tweets objectAtIndex:index] objectForKey:@“text”];包含http://t.co/######的链接,但看起来UITextView似乎没有检测到http://t.co链接。我需要使用UIWebView吗?
答案 0 :(得分:8)
我注意到的一件事是,为了让UITextView识别链接,您需要将selectable设置为YES。例如:
self.bodyTextView = [[UITextView alloc]initWithFrame:myFrame];
[self.bodyTextView setEditable:NO];
//this is the key
[self.bodyTextView setSelectable:YES];
[self.bodyTextView setDataDetectorTypes:UIDataDetectorTypeLink];
[self.bodyTextView setAttributedText:myAttributedText];
答案 1 :(得分:4)
尝试使用此希望对您有所帮助
默认情况下, UITextView 中的链接无法点击。但幸运的是,它们可以通过几行简单的代码启用:
theTweet.editable = NO;
theTweet.dataDetectorTypes = UIDataDetectorTypeLink;
很遗憾,您无法使用可点击的链接获得可编辑的 UITextView 。如果将editable设置为YES,则所有链接都将被视为常规文本。
喜欢这个。
UITextView *theTweet= [[UITextView alloc] initWithFrame:CGRectMake(65, 10, 225, 65)];
theTweet.text = @"http://t.co/######";
theTweet.editable = NO;
theTweet.dataDetectorTypes = UIDataDetectorTypeLink;
[myview addSubview:theTweet];
答案 2 :(得分:3)
你设置了:theTweet.dataDetectorTypes = UIDataDetectorTypeLink; ?
现在你添加了它,我尝试了这段代码:
UITextView *theTweet;
theTweet = [[UITextView alloc] initWithFrame:CGRectMake(65, 10, 225, 65)];
theTweet.text = @"http://t.co/######";
theTweet.editable = NO;
theTweet.dataDetectorTypes = UIDataDetectorTypeLink;
[myview addSubview:theTweet];
它对我很好。
错误必须在其他地方。 (你关闭了可编辑的吗?)
答案 3 :(得分:0)
您需要设置可编辑属性NO
theTweet = [[[UITextView alloc] initWithFrame:CGRectMake(65, 10, 225, 65)] autorelease];
theTweet.editable = NO; //add this line
theTweet.text = [[tweets objectAtIndex:index] objectForKey:@"text"];
theTweet.dataDetectorTypes = UIDataDetectorTypeLink;
[tweetView addSubview:theTweet];
答案 4 :(得分:0)
进行扩展也许很好,所以我们不必记住它...
java -Xss2m QuickSort