Re: Clickable URLs in a UITextView
Re: Clickable URLs in a UITextView
- Subject: Re: Clickable URLs in a UITextView
- From: Brent Gulanowski <email@hidden>
- Date: Sun, 4 Oct 2009 18:30:49 -0400
I think you have to use a UIWebView.
On Sun, Oct 4, 2009 at 11:08 AM, DKJ <email@hidden> wrote:
> I've subclassed a UITextView, and I want it to display clickable URLs. I
> put the URL string in the view using its drawRect: method. But when the view
> is displayed, the URL isn't clickable. Here's the code I'm using:
>
>
> - (id)initWithFrame:(CGRect)frame
> {
> if (self = [super initWithFrame:frame])
> {
> self.editable = NO;
> self.userInteractionEnabled = YES;
> self.dataDetectorTypes = UIDataDetectorTypeAll;
> }
> return self;
> }
>
> - (void)drawRect:(CGRect)rect
> {
> CGRect r = CGRectMake(20, 20, 280, 30);
> NSString *line = @"http://www.erewhon.org";
> [line drawInRect:r
> withFont:[UIFont systemFontOfSize:18.0]
> lineBreakMode:UILineBreakModeWordWrap
> alignment:UITextAlignmentCenter];
> }
> }
>
> Why don't I get a clickable URL in this view?
>
> Rather than simply setting the view's text property, I'm doing it this way
> so I can have different fonts in different lines. No doubt this is why the
> dataDetectorTypes setting isn't doing what I want. But I'd be interested to
> know what's going on behind the scenes here. Is the string actually being
> displayed as a subview of the text view?
>
> dkj
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
Brent Gulanowski
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden