UITableViewCell问题

时间:2010-12-29 04:21:40

标签: iphone ios4

我正在创建一个带有三个标签和一个imageView的自定义可重用UITableViewCell,我将在单元格的dealloc方法中删除它们... 一切正常,但问题是选中时单元格中的文字变黑了... 它和它有点重叠 帮助我避免这个问题...

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
{
    NSLog(@"Address for cel called");
    NameLbl = [[UILabel alloc] initWithFrame:CGRectMake(5,5,140,20)];
    [self.contentView addSubview:NameLbl];
    NameLbl.font =[UIFont fontWithName:@"Times New Roman" size:15];
    NameLbl.font = [UIFont boldSystemFontOfSize:15];
    NameLbl.opaque=YES;
    NameLbl.tag = 1001;

    AddressLbl  = [[UILabel alloc] initWithFrame:CGRectMake(5,25,140,20)];
    [self.contentView addSubview:AddressLbl];
    AddressLbl.font =[UIFont fontWithName:@"Times New Roman" size:15];
    AddressLbl.opaque=YES;
    AddressLbl.tag = 1002;

    CityStateZipLbl = [[UILabel alloc] initWithFrame:CGRectMake(5,50,150,20)];
    [self.contentView addSubview:CityStateZipLbl];
    CityStateZipLbl.opaque=YES;
    CityStateZipLbl.tag = 1003;
    CityStateZipLbl.font =[UIFont fontWithName:@"Times New Roman" size:15];

}
return self;
}



- (void)dealloc {
[CityStateZipLbl release];
[NameLbl release];
[AddressLbl release];

[super dealloc];
}

1 个答案:

答案 0 :(得分:1)

@balu:

我想你想说的是,当你选择一个单元格时,标签的文字颜色仍然是黑色,它不会变成白色?

如果要配置突出显示状态,则

用于UILabel

UILabel *标签;

[label setHighlightedTextColor:[UIColor whiteColor]];

否则你可以为它上传一个截屏:) ..