Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.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 UITableViewCell添加了自定义视图加载问题_Ios_Objective C_Uitableview - Fatal编程技术网

Ios UITableViewCell添加了自定义视图加载问题

Ios UITableViewCell添加了自定义视图加载问题,ios,objective-c,uitableview,Ios,Objective C,Uitableview,您好,我想为我的UITableView添加自定义单元格分隔符,以便在我的cllforrowatinex委托中 if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier] } 在此之后,我将自定义UIView添加到我的cell.content视图中 UIView *lineView =

您好,我想为我的
UITableView
添加自定义单元格分隔符,以便在我的
cllforrowatinex
委托中

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]
}
在此之后,我将自定义
UIView
添加到我的cell.content视图中

 UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width, 1)];

    lineView.backgroundColor = [UIColor colorWithRed:61.0/255 green:80.0/255 blue:118.0/255 alpha:1.0];
    [cell.contentView addSubview:lineView];
但我的问题是,当它第一次加载时,我的分隔器右侧不会进入
UITableView
的edg,但一旦我滚动了表格,它就会转到全宽。为什么呢?我怎样才能解决这个问题

  • 创建自定义
    UITableViewCell

  • 在单元格的
    layoutSubviews
    方法中设置分隔符的框架

  • 或者,如果是这种情况,也可以像这样更改分隔符颜色:

    [self.tableView setSeparatorColor:[UIColor myColor]];
    

    或者我们不能更改默认分隔符颜色吗?您可以,这很容易
    [self.tableView setSeparatorColor:[UIColor myColor]]