私のストーリーボードには、テーブル ビューがあります。JSON ファイル (viewDidLoad にロードされた) からロードされたデータを使用して、そのテーブル ビューを埋めています。
私のUITableViewでは、「プロトタイプセル」を1に設定したので、アクセサリを簡単に選択できます。私のプロトタイプセルには、選択したアイテムの詳細を表示する必要がある新しいビューへのシークがあります。
これを使用してプログラムでセルを埋めています:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *videoTableIdentifier = @"VideoCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:videoTableIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:videoTableIdentifier];
UILabel * title = [[UILabel alloc] initWithFrame:CGRectMake(40,5, 240,20)];
[cell addSubview:title];
[title setText:[[videos objectAtIndex:indexPath.row] objectForKey:@"title"]];
UILabel * detail = [[UILabel alloc] initWithFrame:CGRectMake(40,28, 100,10)];
[cell addSubview:detail];
[detail setText:[NSString stringWithFormat:@"Year: %@", [[videos objectAtIndex:indexPath.row] objectForKey:@"year"]]];
[cell addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:[[videos objectAtIndex:indexPath.row] objectForKey:@"image"]]]];
return cell;
}
スクロールを開始すると、次のことが起こります。
そこで、解決策を探し始めたところ、dequeueReusableCellWithIdentifier:videoTableIdentifier
「nil」に設定する必要があることがわかりました。
それを行っている間、これで問題は解決しましたが、Prototype Cell Accessories とSequeがなくなったので、次のビューに移動できなくなりました。
インターネット上でこれに対する解決策を見つけることができなかったので、これを尋ねることにしました。誰かが助けてくれたら最高です。