我正在使用一個沒有任何故事板的舊Objective-C項目。我需要一個UITableView
來顯示含有3個標籤的UITableViewCell
的結果。任務是在UITableviewCell
Objective C在代碼中設置自動行高度
這裏垂直對齊3個標籤是我萌生標籤:
serviceTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, 200, LONG_MAX)];
[serviceTitleLabel setFont:[UIFont SingPostRegularFontOfSize:16.0f fontKey:kSingPostFontOpenSans]];
[serviceTitleLabel setNumberOfLines:0];
[serviceTitleLabel setTextColor:RGB(51, 51, 51)];
[serviceTitleLabel setBackgroundColor:[UIColor clearColor]];
[serviceTitleLabel setTextAlignment:NSTextAlignmentLeft];
[contentView addSubview:serviceTitleLabel];
statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 30, 200, 30)];
[statusLabel setFont:[UIFont SingPostBoldFontOfSize:12.0f fontKey:kSingPostFontOpenSans]];
[statusLabel setTextColor:RGB(125, 136, 149)];
[statusLabel setBackgroundColor:[UIColor clearColor]];
[contentView addSubview:statusLabel];
costLabel = [[UILabel alloc] initWithFrame:CGRectMake(216, 20, 85, 30)];
costLabel.right = contentView.right - 15;
[costLabel setFont:[UIFont SingPostBoldFontOfSize:16.0f fontKey:kSingPostFontOpenSans]];
[costLabel setTextColor:RGB(51, 51, 51)];
[costLabel setTextAlignment:NSTextAlignmentRight];
[costLabel setBackgroundColor:[UIColor clearColor]];
[contentView addSubview:costLabel];
我們怎樣才能在UITableViewController
調整使得其尺寸將根據標籤尺寸大小?需要在cell和tableview中設置?任何幫助深表感謝。謝謝。
這是現在的屏幕。看不對
它不是我清楚,如果你只有一個的tableView有一個單元或多個單元格 – ddb
你好這是一個動態的tableview與數據從一系列的項目(3標籤是項目屬性) –
我需要了解的是,如果每個單元格應該有其自定義高度或計算出的高度是有效的每個細胞 – ddb