Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.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 容器视图白色背景,iPad Swift问题_Ios_Objective C_Swift - Fatal编程技术网

Ios 容器视图白色背景,iPad Swift问题

Ios 容器视图白色背景,iPad Swift问题,ios,objective-c,swift,Ios,Objective C,Swift,我的问题只发生在iPad上。默认情况下,“我的容器”视图是清晰/透明的。它在iPhone上运行良好,但在iPad上显示时默认为白色背景。大多数自定义UITableView也存在同样的问题 我在下面附上了问题的图片: iPad上的手机背景颜色有问题。我曾经面对过这个问题 我已经通过在代码中将单元格所有组件的背景色更改为清晰的颜色来解决了这个问题 //in cell's awakeFromNib UIView* backgroundView = [[UIView alloc] initWithFra

我的问题只发生在iPad上。默认情况下,“我的容器”视图是清晰/透明的。它在iPhone上运行良好,但在iPad上显示时默认为白色背景。大多数自定义UITableView也存在同样的问题

我在下面附上了问题的图片:


iPad上的手机背景颜色有问题。我曾经面对过这个问题

我已经通过在代码中将单元格所有组件的背景色更改为清晰的颜色来解决了这个问题

//in cell's awakeFromNib
UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
backgroundView.userInteractionEnabled = NO;
backgroundView.backgroundColor = [UIColor clearColor];
self.backgroundView = backgroundView;

self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];

我认为这很有帮助

手机的
ContentView
默认颜色对于
iPhone
iPad
是不同的


你必须在故事板中设置单元格内容视图的背景色,你就完成了。

这基本上是我问题的解决方案,我唯一需要添加的,我将附加swift代码是使用tableViewDelegate的“willDisplayCell”方法

override func tableView(tableView:UITableView,willDisplayCell:UITableViewCell,forRowAtIndexPath-indepath:nsindepath){
var backgroundView:UIView=UIView(帧:CGRect.zeroRect)
backgroundView.backgroundColor=UIColor.clearColor()
cell.backgroundView=背景视图
cell.backgroundColor=UIColor.clearColor()
}

感谢您为我添加图像。这基本上是我问题的解决方案,我唯一需要添加的,我将附加swift代码是使用tableViewDelegate的“willDisplayCell”方法。请查看OP中的解决方案。我认为,使用CellWillAspect方法是一个很好的解决方案:)。但我不使用它,因为一个单元格多次调用它(每次当该单元格消失和出现时),并且每次分配UIView。我更喜欢为我的应用程序中的每种类型的单元格使用自定义类,并用。。。配置自定义参数的方法。必须同时更改单元格及其内容视图的背景颜色吗?我用willDisplayCell方法修复了它,然后从此点开始更改。