可能性のあるいくつかの可能性:
まず、あなたが持っていることを確認するために再確認したいかもしれません
cell.imageView.clipsToBounds = YES;
そうしないと、画像がに収まるようにサイズが変更されるUIImageView
と、画像が画像ビューの境界を越えてにじむ可能性があります。特に、この画像をバックグラウンドキューで読み込んでいるときに、この問題に気づきました。
次にimageView
、バックグラウンドでのプロパティを設定している場合UITableViewCell
(以下の簡略化されたサンプルコードのように)、バックグラウンド画像の読み込みプロセスを開始する前に、空白の画像で画像を適切に初期化することが重要であることを知っておく必要があります。したがって、Webベースのソースからセルをロードするときの非常に一般的なコードの例は次のようになります。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text = ... // you configure your cell however you want
// make sure you do this next line to configure the image view
cell.imageView.image = [UIImage imageNamed:@"blankthumbnail.png"];
// now let's go to the web to get the image
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
UIImage *image = ... // do the time consuming process to download the image
// if we successfully got an image, remember, ALWAYS update the UI in the main queue
dispatch_async(dispatch_get_main_queue(), ^{
// let's make sure the cell is still visible (i.e. hasn't scrolled off the screen)
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell)
{
cell.imageView.image = image;
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.clipsToBounds = YES;
}
});
});
return cell;
}
明らかに、そのようなことをする場合は、[UIImage imageNamed:@"blankthumbnail.png"];
が戻ってこないことを確認nil
する必要があります(つまり、アプリがバンドル内で正常に検出されていることを確認してください)。一般的な問題には、空白のイメージがまったくない、名前が間違っている、[ビルドフェーズ]タブの[バンドルリソースのコピー]の下にあるターゲット設定にイメージが含まれていないなどがあります。
第3に、サブクラス化さUITableViewCell
れたエントリを使用する場合は、、などの標準プロパティ名を使用しないようにする必要UITableViewCell
があります。必ず独自の一意の名前を使用してください。を使用すると、システムはの新しいプロパティとデフォルトのプロパティの間で混乱します。imageView
textLabel
imageView
IBOutlet
imageView
UITableViewCell