その中に aview
をドラッグしUITableView
たものと、2 つUIImageView
の s があります (1 つ目は背景画像を表示し、2 つ目はビューの上部に画像付きの非常に小さなタイトルを表示するだけです)。それらはすべてweak
プロパティに設定されています。tableView には 495 行あり、各セルに画像が読み込まれます。セルを構成するためのコードは次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
int cellNumber = indexPath.row + 1;
NSString *cellImage1 = [NSString stringWithFormat:@"c%i.png", cellNumber];
UIImage *theImage = [UIImage imageNamed:cellImage1];
[cell.imageView setImage:theImage];
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor brownColor]];
[cell setSelectedBackgroundView:bgColorView];
return cell;
}
私はsegue
s を使っているので、delegate メソッドは必要ありません。(この質問にも関係ありません)。問題は、スクロールがスムーズだということです。しかし、スクロールが速すぎると遅くなり、アプリがクラッシュする可能性があります。セルにロードされた png 画像は大きなサイズではなく、それぞれが約 5KB です。デキュー作業が効率的に行われていないようです。速度が遅くなり、メモリ警告メッセージが表示され、クラッシュが発生します。私にできることはありますか?(ビューには他に何もありません)
更新:コードのこの部分も削除しようとしました:
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor brownColor]];
[cell setSelectedBackgroundView:bgColorView];
だめ!