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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to