简体   繁体   中英

Link detection in a UITextView inside a UITableViewCell - iOS 7

I have a chat app. The bubble chat inside a UITableViewCell is composed by a UIImageView (the bubble) and a UITextView created programmatically and it has DataDetectorTypes to detect phone numbers and links. When I have the link in the beginning of the text or the link alone in the cell everything works perfectly, but my problem is when the link is at the end of the UITextView . It gets detect as a link but the click on the link doesn't work.

I have created the UITextView like that:

[self.messageLabel setBackgroundColor:[UIColor clearColor]];
[self.messageLabel setFont:[UIFont fontWithName:@"Helvetica" size:15]];
[self.messageLabel setText:nil];
[self.messageLabel setEditable:NO];
[self.messageLabel setSelectable:YES];
[self.messageLabel setScrollEnabled:NO];
[self.messageLabel setDelaysContentTouches:NO];
[self.messageLabel setDataDetectorTypes:(UIDataDetectorTypePhoneNumber|UIDataDetectorTypeLink)];
[self.messageLabel setTextAlignment:NSTextAlignmentLeft];

Can anyone help me?

try again after increase row height of a cell in [tableView:heightForRowAtIndexPath].

If it works, you need to change of height of cell dynamically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM