Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用UIAppearance设置自定义UITableViewCell的样式_Ios - Fatal编程技术网

Ios 使用UIAppearance设置自定义UITableViewCell的样式

Ios 使用UIAppearance设置自定义UITableViewCell的样式,ios,Ios,我有一个自定义的UITableViewCell,我想使用UIAppearance协议设置它的样式 @interface MyCell : UITableViewCell<UIAppearance> { } @property (nonatomic,weak) UIView *backgroundCellView UI_APPEARANCE_SELECTOR; MyCell.m: -(void) setBackgroundCellView:(UIView *)bac

我有一个自定义的UITableViewCell,我想使用UIAppearance协议设置它的样式

@interface MyCell : UITableViewCell<UIAppearance>
{

}

@property (nonatomic,weak) UIView *backgroundCellView UI_APPEARANCE_SELECTOR;



 MyCell.m: 

  -(void) setBackgroundCellView:(UIView *)backgroundView
{
    NSLog(@"setBackgroundCellView");

    [super setBackgroundView:backgroundView];
}

它将背景分配给少数单元格,但不是所有单元格。通常分配的都在中间。 不能将同一UIImageView分配给多个单元格并尝试显示该单元格。同一UIView不能只是一个子视图层次结构的一部分

相反,需要做的是创建一个自定义背景视图,该视图具有可配置UIImage的UIAppearance


基本上,应该使用UIAppreance而不是背景视图本身来配置背景视图的图像。

视频中的代码不使用UIAppearance协议。当我想要自定义10个uitableview时会发生什么情况呢?它用于更改uitableview的背景,我想你可以为此制作一个customcell
  [[MyCell appearance] setBackgroundCellView:[UIImageView .... with an image]];