Ios 如何确定tableview单元格的高度

Ios 如何确定tableview单元格的高度,ios,uitableview,autolayout,font-size,fixed,Ios,Uitableview,Autolayout,Font Size,Fixed,最近,我编写了一个高度为60.0f的自定义UITableViewCell。当它在不同的设备上运行时,例如iPhone5iPhone6iPhone6+,高度和fontSize会自动更改。如何确定高度 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style r

最近,我编写了一个高度为60.0f的自定义
UITableViewCell
。当它在不同的设备上运行时,例如
iPhone5
iPhone6
iPhone6+
,高度和
fontSize
会自动更改。如何确定高度

  - (id)initWithStyle:(UITableViewCellStyle)style
        reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (!self) {
            return nil;
        }       
        self.textLabel.adjustsFontSizeToFitWidth = NO;
        self.textLabel.font = [UIFont systemFontOfSize:15.0f];
        self.detailTextLabel.adjustsFontSizeToFitWidth = NO;
        self.detailTextLabel.font = [UIFont systemFontOfSize:12.0f];
        self.detailTextLabel.numberOfLines = 0;
        _switchButton = [[UISwitch alloc] initWithFrame:CGRectMake(250, 9, 30, 20)];
        _switchButton.tag = 400;
        [_switchButton addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_switchButton];

        _button = [UIButton buttonWithType:UIButtonTypeCustom];
        _button.frame = CGRectMake(250, 9, 60, 30);
        [_button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button];
        _button.backgroundColor = [UIColor clearColor];

        return self;
    }
在控制器中:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60.0;
}

self.detailTextLabel.numberOfLines
设置为精确值,而不是0。这将关闭标签的自动大小调整。

请显示tableview创建代码,可能您需要将UITableView的行高更改为60.0f not UITableView AutomaticDimensions抱歉,以下是创建:-(CGFloat)tableview:(UITableView*)tableview HeightForRowatineXpath:(NSIndexPath*)indexPath{return 60.0;}然后尝试不使用UITableViewCell中的textLabel和detailTextLabel。在自己的属性中设置自己的标签。