相关疑难解决方法(0)

UITextViews在iOS 7中的UITableView链接检测错误中

我有自定义UITableViewCells包含UITextView.我在Interface Builder中打开了UITextView中的链接检测.当我第一次加载表视图时,一切似乎都在工作,但是当我在表视图中向上和向下滚动时,链接检测会搞砸.具体来说,只有常规文本(通常最初显示)的单元格显示为链接(文本视图中的所有文本都显示为蓝色并且是活动链接),并且链接指向某些文本中的对象.其他表视图单元格.例如,链接可能指向位于不同表视图单元格中的网站,或者将电子邮件发送到位于不同表格视图单元格中的地址.

看起来当表视图单元格被重用时,即使正在更新文本视图文本,链接也会以某种方式被保存.

这只发生在iOS 7,而不是iOS 6.它发生在模拟器和我的设备上.

这是代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *sectionKey = [self.orderedSectionKeys objectAtIndex:indexPath.section];
    NSDictionary *infoDictionary = [[self.tableViewData objectForKey:sectionKey] objectAtIndex:indexPath.row];

    static NSString *cellIdentifier = @"InfoDefaultTableViewCell";
    InfoDefaultTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {        
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"InfoTableViewCells" owner:self options:nil];
        cell = [topLevelObjects objectAtIndex:0];
    }

    cell.bodyTextView.text = [infoDictionary objectForKey:@"description"];

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

有谁知道这里发生了什么,以及如何解决它?


我尝试在设置文本视图文本后添加此代码,尝试重置链接:

cell.bodyTextView.dataDetectorTypes = UIDataDetectorTypeNone;
cell.bodyTextView.dataDetectorTypes = UIDataDetectorTypeAddress | UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber;
Run Code Online (Sandbox Code Playgroud)

但它并没有改变我所看到的行为.

uitableview uitextview ios ios7

46
推荐指数
5
解决办法
1万
查看次数

标签 统计

ios ×1

ios7 ×1

uitableview ×1

uitextview ×1