Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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
Iphone 在UITableViewCell上绘制垂直分隔符_Iphone_Objective C_Uitableview - Fatal编程技术网

Iphone 在UITableViewCell上绘制垂直分隔符

Iphone 在UITableViewCell上绘制垂直分隔符,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,我有一个简单样式的UITableView,它的单元格是UITableViewCell的一个子类 在cell子类中,我重写了drawRect以将此绘图代码放入(用于垂直分隔符): 效果很好。但是,我现在已将tableview样式更改为“分组”。这条线根本没有画出来。尽管进行了设置,但断点显示调用了drawRect方法 我想避免子类UIView只是为了画一条小的线,特别是因为我已经子类化了tableview单元格,我只想在单元格上绘制。那么,为什么代码突然停止在分组的tableview上工作?在UI

我有一个简单样式的UITableView,它的单元格是UITableViewCell的一个子类

在cell子类中,我重写了drawRect以将此绘图代码放入(用于垂直分隔符):

效果很好。但是,我现在已将tableview样式更改为“分组”。这条线根本没有画出来。尽管进行了设置,但断点显示调用了drawRect方法


我想避免子类UIView只是为了画一条小的线,特别是因为我已经子类化了tableview单元格,我只想在单元格上绘制。那么,为什么代码突然停止在分组的tableview上工作?

UITableViewCell
子类中重写
drawRect
不是一个好主意。如果不想设置自定义单元格的
backgroundView
,则只需添加1px宽的简单
UIView

UIView* vertLineView = [[UIView alloc] initWithFrame:CGRectMake(80, 0, 1, 44)];
vertLineView.backgroundColor = [UIColor redColor];
[self.contentView addSubview:vertLineView];

试着重新设置模拟器n CLENING ur PRJCTAGGREED。或者你可以在单元格中添加一个带有自定义线条图像的UIImageView。我想我错了。在某些情况下,覆盖
drawRect
可能是合理的。
UIView* vertLineView = [[UIView alloc] initWithFrame:CGRectMake(80, 0, 1, 44)];
vertLineView.backgroundColor = [UIColor redColor];
[self.contentView addSubview:vertLineView];