3

TTTAttributedLabel を UITableViewCell に統合しようとしています。これは本当に単純な統合であり、古い UILabel を TTTAttributedLabel に置き換えることだけが目的でした。これが私がしたことです。

  1. ストーリーボードに移動し、カスタム UITableViewCell 内の UILabel を選択し、そのクラスを TTTAttributedLabel に変更します
  2. 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;
    

しかし、リンク検出は機能していません。それは単なるプレーンテキストです。間違っていることをデバッグするにはどうすればよいですか?

4

1 に答える 1