2011-06-14 3 views
0

私は興味がありますが、UITableViewCellのカスタムbackgroundViewを設定するとパフォーマンスが向上しますか?backgroundView:willDisplayCellまたはinitを設定するとパフォーマンスが向上しますか?

オプション0)サブクラスのUITableViewCellのinitメソッド

@implementation CustomCell 
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier andReleases:(NSArray*)releases { 

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 
     self.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tablecell.png"]] autorelease]; 
    } 
    return self; 
} 

オプション1)委任willDisplayCell方法

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 
    cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tablecell.png"]] autorelease]; 
} 
+0

質問に答えた場合は回答を受け入れます。この場合、私はあなたがそう信じました。ありがとう! – Keller

答えて

4

作成したときに一度の背景を設定するので、オプション0はこのケースで優れていますセルを表示するたびにwillDisplayCellが設定されます。 UITableViewCellsを再利用するので、セルを短時間で作成して表示することができます。

しかし、早すぎる最適化を避け、パフォーマンスが十分ではないと感じた場合にのみ最適化してください。

関連する問題