カスタムセルクラスを作成しています。私はinitメソッドで異なるタイプのサブビューを作成していますが、CGRectZeroとしてフレームを配置しています。私layoutSubviews法で複数のUITableViewCell型の実装
self.subTitleLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];[self.contentView addSubview:self.subTitleLabel];
self.scannedProductLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
[self.contentView addSubview:self.scannedProductLabel];
self.requestStatusLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
[self.contentView addSubview:self.requestStatusLabel];
、私は私の必要性に基づいてこれらのラベルを使用しています。同様に、あるタイプのセルでは、最初のラベルを使用し、他のタイプでは別のラベルを使用します。
if ([self.cellType isEqualToString:@"CustomerDetails"]) {
//self.productImageView.frame = CGRectMake(aContentRect.origin.x + kCellOffset, 0.0f, aTitleCellWidth , floorf(aHeight/4));
self.titleLabel.frame = CGRectMake(aContentRect.origin.x + kCellOffset, 0.0f, aTitleCellWidth , floorf(aHeight/2));
self.subTitleLabel.frame = CGRectMake(aContentRect.origin.x + kCellOffset, floorf(aHeight/2), aTitleCellWidth, floorf(aHeight/4));
self.requestStatusLabel.frame = CGRectMake(aContentRect.origin.x + kCellOffset, floorf((aHeight/2) + (aHeight/4)), aTitleCellWidth , floorf(aHeight/4));
}
私の質問は、それは、メモリの観点からこれを行うには良いアイデアです。私の目的は解決されたものの、私のカスタムセルオブジェクトにはメモリには表示されていないサブビューが含まれています。はいの場合、このようなシナリオの代替アプローチは何ですか?
これは完璧に見えます。ありがとう。 – Abhinav