outlier cell in three20
I sometimes see the following issue in my cell using three20:
The TTStyledTextLabel is empty or has no text.. it should have something in there as the others have.
The code is very simple:
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];
UI开发者_StackOverflow社区ImageView * 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];
}
By default the text color the white, so it might be showing up, but you just can't see it :-)
Try changing the text color: _textLabel.textColor = [UIColor blueColor];
Also, note that if you're using TTStyledText, you can't use a standard UIKit label. You need to use TTStyledTextLabel from the three20 library, as such:
_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];
Verify that the text is not nil or has any special characters that might not make it past your json/xml parser.
精彩评论