テーブル セルで UILabel の高さを変更しようとしています。私の場合、テーブルは動的で、2 つの UILabel を使用してカスタマイズしました。Table にはちょうど 11 項目が表示されますが、セルのうち 2 つは複数行のテキスト UILabel に対応する必要があります。次のように、2 つのセルの高さを選択的に増やしました。
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 3 || indexPath.row == 10)
return 100;
else
return 46;
}
しかし、これら 2 つのセルだけの UILabel の高さを増やす必要もあります。次のコードを使用してみました (このサイトの他の例も試しました)。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellId";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
UILabel *DetailLabel = (UILabel *)[cell.contentView viewWithTag:10];
UILabel *DetailText = (UILabel *)[cell.contentView viewWithTag:20];
if(indexPath.row == 3 || indexPath.row ==10){
[DetailText setText:[self.EmployerViewText objectAtIndex:[indexPath row]]];
DetailText.lineBreakMode = NSLineBreakByWordWrapping;
DetailText.font = [UIFont systemFontOfSize:17.0f];
DetailText.numberOfLines = 0;
DetailText.frame = CGRectMake(0, 0, 317, 80);
[DetailText sizeToFit];
}else{
[DetailText setText:[self.EmployerViewText objectAtIndex:[indexPath row]]];
}
[DetailLabel setText:[self.EmployerViewLabel objectAtIndex:[indexPath row]]];
return cell;
}
残念ながら、UILable のサイズは変更されていません。誰かが私が間違っていることを指摘できますか?