私のTableViewを廃止予定のinitWithFrame:reuseIdentifier:
から更新したいと思います。initWithFrameとinitWithStyle
私のテーブルビューはカスタムセルを使用します。
どこでもinitWithStyle:
を使用すると言いますが、動作やセルはいかなる形でもinitWithFrame:CGRectZero reuseIdentifier:
から変更されません。
私がinitWithStyle:UITableViewCellStyleDefault reuseIdentifier:
でビルドしているとき、セルは空白になります(つまり、カスタムセルは機能しません(何らかのスタイルで初期化されていますか?))。
セルが初期化された後(デキューされなかった場合)、セルにテキストを設定します。しかし、これはinitWithStyle:reuseIdentifier:
を使用すると設定されませんが、initWithFrame:CGRectZero
と動作します。使用されるinitメソッド(initWithStyle
)を除いて、コードは変更されません。
セルが作成(または再利用)された後、これらの行は入れ:中
cell.newsItemNameLabel.text = @"test";
NSLog(@"NewsItemName: %@",cell.newsItemNameLabel.text);
結果 "NewsItemName:(ヌル)"
誰もがアイデアを持って?両者の本当の違いは何ですか?
CustomCell
カスタムセルのクラスの名前です
- (CustomCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
CustomCell *cell = (CustomCell *)(UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell.
cell.textLabel.text = NSLocalizedString(@"Detail", @"Detail");
return cell;
}
を:
はcellForRowAtIndexPath
の
私はあなたのクラスの多くを投稿する必要があるかもしれないと思います。 – picciano