我正在尝试将 TTTAttributedLabel 集成到 UITableViewCell 中。这实际上只是一个简单的集成,我只想用 TTTAttributedLabel 替换旧的 UILabel。这就是我所做的。
- 转到 Storyboard 并选择自定义 UITableViewCell 中的 UILabel 并将其类更改为 TTTAttributedLabel
回到 UITableViewController 子类,包含 TTTAttributedLabel.h,修改
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
如下: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;
但是链接检测不起作用。这只是纯文本。如何调试我做错了什么?