简体   繁体   English

UITableViewCell内部的UITextView中的链接检测-iOS 7

[英]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. UITableViewCell内的气泡聊天由UIImageView (气泡)和以编程方式创建的UITextView组成,并且具有用于检测电话号码和链接的DataDetectorTypes 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 . 当我将链接放在文本开头或将链接单独放在单元格中时,一切都将正常运行,但是我的问题是,当链接位于UITextView的末尾时。 It gets detect as a link but the click on the link doesn't work. 它被检测为链接,但单击链接不起作用。

I have created the UITextView like that: 我创建了这样的UITextView

[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]. [tableView:heightForRowAtIndexPath].增加单元格的行高后重试[tableView:heightForRowAtIndexPath].

If it works, you need to change of height of cell dynamically. 如果可行,则需要动态更改单元格的高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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