UITableView コントローラー、UITableView xib、および xib を持つ 2 つの UITableViewCell サブクラスがあります。xib ごとに個別のセルをドラッグしました。最初のセルの高さは 115 で、他のセルの高さはデフォルトです。コントローラーで cellForRowAtIndexPath が呼び出されると、最初の行をより大きなセルに設定する条件ステートメントがあります。その後のすべての行は、他のセルに設定されます。大きなセルがレンダリングされているにもかかわらず、デフォルト セルは最初のセルがデフォルトよりも大きいという事実を認識していないため、デフォルト セルが大きなセルに重なっています。私の言いたいことを示すために、大きなセルの下部に distanceLabel アウトレットを設定します。
注: 2.3 マイルは最初のセルの一部です。
- (void)viewDidLoad
{
[super viewDidLoad];
// load the cell nib
UINib *nib = [UINib nibWithNibName:@"CustomViewCell" bundle:nil];
UINib *bigNib = [UINib nibWithNibName:@"BigCell" bundle:nil];
//Register the nib
[[self tableView] registerNib:nib forCellReuseIdentifier:@"CustomViewCell"];
[[self tableView] registerNib:bigNib forCellReuseIdentifier:@"BigCell"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
BigCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BigCell"];
NSString *title = [self.frontList objectAtIndex:indexPath.row];
[[cell nameLabel] setText:title];
[[cell distanceLabel] setText:@"2.3 miles"];
return cell;
} else {
CustomFrontCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomViewCell"];
NSString *titles = [self.frontList objectAtIndex:indexPath.row];
[[cell nameLabel] setText:titles];
return cell;
}
}
これらのセルを正しい間隔と高さでレンダリングするにはどうすればよいですか?