English 中文(简体)
关税中可加利用的单位 观光电池
原标题:Overlapping UILabels in custom UITableView cells

I have problem with overlapping labels in custom cells. Here are init and layout methods for this cells:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self)
    {
        self.img = [[[UIImageView alloc] init] autorelease];
        [self.contentView addSubview:self.img];

        self.p = [[[UILabel alloc] init] autorelease];
        [self.p setTextAlignment:UITextAlignmentCenter];
        [self.p setFont:[UIFont fontWithName:@"Helvetica" size:10.0]];
        [self.p setLineBreakMode:UILineBreakModeTailTruncation];
        [self.p setNumberOfLines:1];
        [self.p setTextColor:[UIColor whiteColor]];
        [self.p setBackgroundColor:[UIColor redColor]];
        [self.p setText:@"PREMIERA"];
        [self.contentView addSubview:self.p];        

        self.g = [[[UILabel alloc] init] autorelease];
        [self.g setTextAlignment:UITextAlignmentLeft];
        [self.g setFont:[UIFont fontWithName:@"Helvetica-Bold" size:12.0]];
        [self.g setLineBreakMode:UILineBreakModeTailTruncation];
        [self.g setNumberOfLines:1];
        [self.contentView addSubview:self.g];

        self.t = [[[UILabel alloc] init] autorelease];
        [self.t setTextAlignment:UITextAlignmentLeft];
        [self.t setFont:[UIFont fontWithName:@"Helvetica-Bold" size:14.0]];
        [self.t setMinimumFontSize:12.0f];
        [self.t setAdjustsFontSizeToFitWidth:YES];
        [self.t setLineBreakMode:UILineBreakModeTailTruncation];
        [self.t setNumberOfLines:1];
        [self.contentView addSubview:self.t];

        self.o = [[[UILabel alloc] init] autorelease];
        [self.o setTextAlignment:UITextAlignmentLeft];
        [self.o setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
        [self.o setLineBreakMode:UILineBreakModeTailTruncation];
        [self.o setNumberOfLines:1];
        [self.contentView addSubview:self.o];
    }

    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];

    self.img.frame = CGRectMake(0, 0, 40, 60);
    self.p.frame = CGRectMake(0, 0, 0, 0);
    self.g.frame = CGRectMake(0, 0, 0, 0);
    self.t.frame = CGRectMake(0, 0, 0, 0);
    self.o.frame = CGRectMake(0, 0, 0, 0);

    CGSize pSize = CGSizeMake(0, 0);
    CGSize gSize = CGSizeMake(0, 0);
    CGSize tSize = [self.t.text sizeWithFont:self.t.font constrainedToSize:CGSizeMake(230, 16) lineBreakMode:self.t.lineBreakMode]; 
    CGSize oSize = [self.o.text sizeWithFont:self.o.font constrainedToSize:CGSizeMake(230, 16) lineBreakMode:self.o.lineBreakMode];


    if (self.jestPremiera)
    {
        pSize = [self.p.text sizeWithFont:self.p.font constrainedToSize:CGSizeMake(60, 16) lineBreakMode:self.p.lineBreakMode];    
        gSize = [self.g.text sizeWithFont:self.g.font constrainedToSize:CGSizeMake(175, 16) lineBreakMode:self.g.lineBreakMode];
        self.p.frame = CGRectMake(50, 5, 60, pSize.height);
        self.p.hidden = NO;
        self.g.frame = CGRectMake(115, 5, 175, gSize.height);
    }
    else
    {
        gSize = [self.g.text sizeWithFont:self.g.font constrainedToSize:CGSizeMake(230, 16) lineBreakMode:self.g.lineBreakMode];            
        self.p.hidden = YES;
        self.g.frame = CGRectMake(50, 5, 230, gSize.height);
    }

    self.t.frame = CGRectMake(50, 5 + gSize.height, 230, tSize.height);
    self.o.frame = CGRectMake(50, 5 + gSize.height + tSize.height, 230, oSize.height);            
}

通常,这项工作(仅限在3G装置上)按样进行:

谁能告诉我这种行为的原因是什么,我能做些什么?

问题回答

请设法通过利用国家安保监督记录仪对标签框架进行清点;

我认为最好的解决办法是,如果你在贴上这些标签时用标号来界定每一个标签。 现在,当你们需要这些标签时,只是审查这些标签。

   yourlabelname = (UILabel *)[cell.contentView viewWithTag:yourLabelTagNumber];

页: 1 DidAppear 仅重载表;





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签