UITextViews in a UITableView link detection bug in iOS 7

后端 未结 13 762
醉梦人生
醉梦人生 2020-12-01 07:19

I have custom UITableViewCells that contain a UITextView. I have link detection in the UITextView turned on in Interface Builder. When I first load the table view, everythin

13条回答
  •  执笔经年
    2020-12-01 07:55

    As any of the above solutions worked for me, a workaround I've found is to create your UITextView when you are supposed to update the text for each cell instead of reusing in the reusable cell.

    Your code in the UITableViewCellDataSource would be :

    - (void)updateDescriptionWithText:(NSString *)descriptionText
    {
        UITextView *descriptionTV = [[UITextView alloc] initWithFrame:aFrame];
        [descriptionTV setScrollEnabled:NO]; 
        [descriptionTV setEditable:NO]; 
        [descriptionTV setDataDetectorTypes:UIDataDetectorTypeLink]; 
        if ([descriptionV respondsToSelector:@selector(setSelectable:)]) 
         [descriptionTV  setSelectable:YES];
        [descriptionTV setText:descriptionText];
        [self addSubview:descriptionTV];
    }
    

    And in the UITableViewCell:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
       ***your init code***
    
       [cell updateDescriptionWithText:description];
    }   
    

提交回复
热议问题