私はUIAppearanceを使用して、自分のアプリケーションでテーブルセルの背景イメージを設定しました。iOS - UiTableviewCell - 一度に1つのセルにのみ表示される背景画像
[[UITableViewCell appearance] setBackgroundView:[ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"list_bg.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]];
ただし、リストを表示すると、背景画像は画面上のセルの1つにのみ設定されます。私が画面をスクロールすると、背景画像は表示されているセルに設定されますが、他の表示されているセルにはこのbg画像が設定されません。
誰でも何が起こっているのかわかりますか?私はUITableviewCellのUIAppearanceを設定することで、このタイプのすべてのインスタンスが自動的に背景イメージを取得すると考えました。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"plantCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"PlantListCell" owner:self options:nil];
cell = _plantCell;
self.plantCell = nil;
}
Plant *plant = [self.fetchedResultsController objectAtIndexPath:indexPath];
UIImageView *thumbnail = (UIImageView *)[cell viewWithTag:1];
thumbnail.image = [UIImage imageNamed:[plant.name stringByAppendingString:@"_S"]];
UILabel *label = (UILabel *)[cell viewWithTag:2];
label.text = plant.name;
UIImageView *set = (UIImageView *)[cell viewWithTag:3];
set.image = [UIImage imageNamed:@"set"];
UIImageView *favourite = (UIImageView *)[cell viewWithTag:4];
favourite.image = [UIImage imageNamed:@"fav"];
return cell;
}
乾杯。大丈夫です。 UIAppearanceを使用するのではなく、直接BG BGイメージを設定するだけで解決しました。 1つか2つのテーブルのためのそれの罰金が、しかしあなたがたくさんある場合。私は許可を得た後、私のコードを8時間以内に回答に添付します。ブライアン –
クール。正しい答えとしてこれをチェックしてください。 – thebarcodeproject