Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.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 为TableView分区添加背景_Ios_Objective C_Uitableview_Background Image_Sections - Fatal编程技术网

Ios 为TableView分区添加背景

Ios 为TableView分区添加背景,ios,objective-c,uitableview,background-image,sections,Ios,Objective C,Uitableview,Background Image,Sections,我有一个动态多行的部分,我需要将所有部分与背景分开,如下图所示 特别是所有路段的边界线。请让我知道如何才能做到这一点 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; { return ProductArray.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sect

我有一个动态多行的部分,我需要将所有部分与背景分开,如下图所示

特别是所有路段的边界线。请让我知道如何才能做到这一点

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
{
    return  ProductArray.count;  
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSArray *arr = [ProductArray objectAtIndex:section];
    return arr.count;    
}
请参考这个


我尝试添加页眉和页脚,但我不明白如何为整个部分添加矩形框图像。

在导出视图后将视图放入单元格。并使用此方法来cellForRowAtIndexPath

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewCell" forIndexPath:indexPath];
                [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    cell.viewBackGround.backgroundColor = [UIColor redColor];
    return cell;
}

对于上述要求,我建议您采用以下方法

仅创建一个包含多行的节

  • UITableView
    的每一行都有
    UITableView单元格
  • UITableViewCell
    create content视图中,我们将为其添加边框
  • UITableViewCell
    的每一行将有另一个
    UITableView
    (在内容视图内),其方法由
    UITableViewCell
    单元格处理
  • 根据行数更改
    UITableView
    (内部)高度
  • 根据行数+订单ID标题提供
    UITableViewCell
    的高度

  • 请提供您迄今为止尝试的示例。您可以在单元格中使用圆角半径或颜色查看UIView。请查看