Ios UIAppearance未设置自定义UITableViewCell的样式

Ios UIAppearance未设置自定义UITableViewCell的样式,ios,Ios,这是一个奇怪的问题!我正在使用UIAppearance API设置UITableViewCells的样式。我使用以下代码设置UITableViewCell的样式 // table cell id tableCellAppearance = [UITableViewCell appearance]; [tableCellAppearance setBackgroundView:[theme imageViewForTableViewCellBackground]]; // tab

这是一个奇怪的问题!我正在使用UIAppearance API设置UITableViewCells的样式。我使用以下代码设置UITableViewCell的样式

// table cell
    id tableCellAppearance = [UITableViewCell appearance];
    [tableCellAppearance setBackgroundView:[theme imageViewForTableViewCellBackground]];

// table cell
-(UIImageView *) imageViewForTableViewCellBackground
{
    UIImageView *backgroundView = [[UIImageView alloc] init];
    [backgroundView setImage:[UIImage imageNamed:@"tile_heading_background"]];

    return backgroundView;
}

当我运行应用程序并看到UITableViewCells时,UITableView中只有1个单元格设置了样式。中间的细胞。为什么呢

创建一个
CustomUITableViewCell
并实现
协议

CustomCell.h

@interface CustomCell : UITableViewCell <UIAppearance>

@property (nonatomic, weak) UIColor *backgroundCellColor UI_APPEARANCE_SELECTOR;
最后在视图中使用自定义单元格,并设置背景或图像

[[CustomCell appearance] setBackgroundCellColor:[UIColor redColor]];

在何处调用此方法imageViewForTableViewCellBackground?只是一个帮助器方法,用于将UIImageView设置为UITableViewCell的背景。上述代码在应用程序委托中仅调用一次。我认为问题在于单元格是动态生成的,而外观API不支持将样式应用于动态生成的控件。为什么不实现CustomTableViewCell?我确实实现了自定义表视图单元格,但我希望使用UIAppearance API对其进行样式设置,因为我有许多自定义单元格。您可以显示代码是什么?因为你需要实现ProtocolSweet!我会试试看。谢谢你的提示!我试过了,但没有成功。我试图更改UITableViewCell的背景视图,但它没有将样式应用于所有UITableViewCell。@johndoe请尝试此操作。它有与视频相关的工作代码。这不是您要查找的吗?我已经在我的应用程序中使用了它,它工作正常,你试过了吗?
[[CustomCell appearance] setBackgroundCellColor:[UIColor redColor]];