Reputation: 8268
I am trying to integrate TTTAttributedLabel into a UITableViewCell. It's really just a simple integration and all I wanted to was to substitute the old UILabel with TTTAttributedLabel. Here's what I did.
Come back to the UITableViewController subclass, include TTTAttributedLabel.h, and modify (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
like this:
static NSString *CellIdentifier = @"Post";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
TTTAttributedLabel *label = (TTTAttributedLabel *)[cell viewWithTag:801];
label.text = [self.post valueForKey:@"content"];
label.enabledTextCheckingTypes = NSTextCheckingTypeLink;
label.userInteractionEnabled = YES;
label.delegate = self;
return cell;
But the link detection is not working. It's just plain text. How can I debug what I am doing wrong?
Upvotes: 3
Views: 4082
Reputation: 867
I think you need to set your text after enabledTextCheckingTypes = NSTextCheckingTypeLink
label.enabledTextCheckingTypes = NSTextCheckingTypeLink;
label.userInteractionEnabled = YES;
label.delegate = self;
label.text = [self.post valueForKey:@"content"];
Upvotes: 5