カスタマイズするために UITableViewCell をサブクラス化しましたが、何かが足りないと思います: 1) 動作していない、2) 混乱していることがいくつかあります。.xib ファイルの外観をカスタマイズすると共に、backgroundView も変更しましたが、その部分は正常に動作しています。私が最も理解していない/最も混乱している部分は init メソッドなので、ここに投稿しました。それが正しいことが判明した場合は、原因である可能性のあるコードをさらに投稿できるように教えてください。
これは、私がカスタマイズした init メソッドです。私は「スタイル」のアイデアについて混乱していて、通常の UITableViewCell を別の backgroundView で返しているだけだと思います。つまり、.xib を参照したり、.backgroundView を自己から変更したりする以外に何かを行うものは何もありません。
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier wait: (float) wait fadeOut: (float) fadeOut fadeIn: (float) fadeIn playFor: (float) playFor
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
CueLoadingView* lview = [[CueLoadingView alloc] initWithFrame:CGRectMake(0, 0, 320, 53)];
self.backgroundView = lview;
[self setWait:wait]; // in turn edits the lview through the backgrounView pointer
[self setFadeOut:fadeOut];
[self setFadeIn:fadeIn];
[self setPlayFor:playFor];
}
return self;
}
.xib といくつかのセッターとゲッターを除いて、これはセルの取得に関連するコードの唯一の実際の部分です。
追加情報:
1) これは、クラスにリンクされている私の .xib です。
2) これは、UITableView (デリゲート/ビュー コントローラー) を呼び出し/作成するコードです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"CueTableCell";
CueTableCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[CueTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier wait:5.0 fadeOut:1.0 fadeIn:1.0 playFor:10.0];
[cell updateBarAt:15];
}
return cell;
}