setFrame不适用于UITableView单元格的UITextLabel

setFrame不适用于UITableView单元格的UITextLabel,uitableview,Uitableview,我无法设置UITableViewCell的UITextLabel的框架。我创建了一个CGRect并将其设置为框架,但这似乎不起作用。下面代码中设置的UITextLabel的所有其他属性(彩色字体和文本)都将根据需要呈现 UITableViewCell *c = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if(!c) { c = [[UITableViewCell all

我无法设置UITableViewCell的UITextLabel的框架。我创建了一个CGRect并将其设置为框架,但这似乎不起作用。下面代码中设置的UITextLabel的所有其他属性(彩色字体和文本)都将根据需要呈现

 UITableViewCell *c = [tableView dequeueReusableCellWithIdentifier:@"Cell"];

        if(!c)
        {
            c = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
        }

NSString *soundName = [[soundNames objectAtIndex:[indexPath row]] valueForKey:@"Name"];
        UIColor *whiteColor = [UIColor whiteColor];
        [[c textLabel] setTextColor:whiteColor];
        [[c textLabel] setText:soundName];
        [[c textLabel] setFont:[UIFont fontWithName:@"Gill Sans" size:17]];

        CGRect textLabelFrame = CGRectMake(50, 7, 270, 29);
        [[c textLabel] setFrame:textLabelFrame];

        return c;

有什么想法吗?

每次显示单元格时,
textlab
的框架都会在
layoutSubviews
方法中更改。您可以覆盖
layoutSubviews
方法并在那里设置自定义框架,或者只需将您自己的
UILabel
和预定义框架添加到单元格中