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"]; contains a link with http://t.co/###### but it doesn't seem like the UITextView is detecting http://t.co links. Do I need to use a UIWebView instead?
One thing I've noticed is that in order for UITextViews to recognize links, you need to set selectable to YES. Example:
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];
did you set: theTweet.dataDetectorTypes = UIDataDetectorTypeLink; ?
Now that you added that, I tried this code:
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];
and it works fine with me.
The error must be somewhere else. (did you turn off editable too?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With