三个异常值细胞20

时间:2011-07-25 05:59:06

标签: iphone objective-c ipad three20

我有时会在使用three20的单元格中看到以下问题:

enter image description here

TTStyledTextLabel为空或没有文本..它应该有其他内容。

代码非常简单:

 TTStyledText * text = [TTStyledText textFromXHTML:group.name lineBreaks:YES URLs:NO]; 
        text.font = [UIFont fontWithName:@"ArialMT" size:18.0];
        _main_title.text = text;


- (void)prepareForReuse {
    [super prepareForReuse];
    _avatar.urlPath = nil;
    [_avatar removeGestureRecognizer:self.tapGesture];
    self.accessoryView = nil;
    UIImageView * lock = (UIImageView *)[self viewWithTag:-1];
    UIImageView * star = (UIImageView *)[self viewWithTag:-2];
    UILabel * star_creator = (UILabel *)[self viewWithTag:-3];
    if (lock != nil)
        [lock removeFromSuperview];
    if (star != nil)
        [star removeFromSuperview];
    if (star_creator != nil)
        [star_creator removeFromSuperview];

    int index = -4;
    TTImageView * avatar = (TTImageView *)[self viewWithTag:index];
    while (avatar != nil){
        [avatar unsetImage];
        index--;
        avatar = (TTImageView *)[self viewWithTag:index];
    }
    [_avatar unsetImage];
}

2 个答案:

答案 0 :(得分:1)

默认情况下,文字颜色为白色,因此可能会显示,但您无法看到它: - )

尝试更改文字颜色:     _textLabel.textColor = [UIColor blueColor];

另请注意,如果您使用的是TTStyledText,则无法使用标准的UIKit标签。您需要使用three20库中的TTStyledTextLabel,如下所示:

_textLabel = [[TTStyledTextLabel alloc] init];
_textLabel.font = [UIFont systemFontOfSize:14];
_textLabel.contentInset = UIEdgeInsetsMake(10, 10, 10, 10);
_textLabel.userInteractionEnabled = NO;
_textLabel.backgroundColor = [UIColor clearColor];
[self.view addSubview:_textLabel];

_textLabel.text = [TTStyledText textFromXHTML:@"MY TEXT HERE" lineBreaks:YES URLs:YES];
[_textLabel sizeToFit];
_textLabel.font = [UIFont fontWithName:@"ArialMT" size:18.0];
_textLabel.textColor = [UIColor blueColor];

答案 1 :(得分:0)

验证文本是否为nil或者是否有任何特殊字符可能无法通过json / xml解析器。