单元分离重叠单元iOS

单元分离重叠单元iOS,ios,tableview,Ios,Tableview,我在iPhone应用程序中有一个表视图。我有两个动态定制细胞板条箱和细胞之间的两个他们分开。故事板仅显示单元格,但分隔符在应用程序中编码。分隔符覆盖第二个单元格并覆盖顶部的部分,包括一些文本。我可以做些什么来修复此重叠 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *c=nil; if

我在iPhone应用程序中有一个表视图。我有两个动态定制细胞板条箱和细胞之间的两个他们分开。故事板仅显示单元格,但分隔符在应用程序中编码。分隔符覆盖第二个单元格并覆盖顶部的部分,包括一些文本。我可以做些什么来修复此重叠

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *c=nil;
    if (indexPath.row==0) {
        static NSString *CellIdentifier = @"AreaCell";
        LSAreaCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
        APLArea *area=[self getAreaForIndexPath:indexPath];
        cell.areaImageView.image=[UIImage imageNamed:area.imageName1];
        c=cell;
    }
    else
    {
        static NSString *QuoteCellIdentifier = @"QuoteCellIdentifier";

        APLQuoteCell *cell = (APLQuoteCell*)[tableView dequeueReusableCellWithIdentifier:QuoteCellIdentifier];
        cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"binding_light"]];

        cell.subarea = [self getSubareaForIndexPath:indexPath];
        c=cell;

        //I put in a seperator on aug 14.  it was supposed to be released!!!
        UIView *cellSeparator = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320 ,35)];
        [cellSeparator setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin |
         UIViewAutoresizingFlexibleRightMargin |
         UIViewAutoresizingFlexibleWidth];
        [cellSeparator setContentMode:UIViewContentModeTopLeft];
        [cellSeparator setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"spacer"]]];
        [cell addSubview:cellSeparator];

       // self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"binding_light"]];
    }
    return c;
}

我假设您希望此自定义分隔符完全位于两个单元格之间

如果是这样的话,您基本上需要首先设置tableview分隔符样式,如图所示

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

然后,您必须在表视图单元格中包含足够的空间来容纳分隔符。您可以增加每个单元格的高度,也可以缩小分隔符以修复重叠。这些更改将在分隔符上的initWithFrame或tableview的cellWithHeight中发生

是的,我希望它完全位于两个单元格之间。如果我理解正确,那么重叠是正常的?分隔符总是与相邻的单元格重叠?然后我应该通过把电池变大,把标签移下来来解决这个问题?我想那会管用的。我会检查并标记你的答案是否正确。是的,如果你只是将其添加为单元格的子视图,那么该单元格框架实际上不会改变。因此,您需要在单元格高度中考虑分隔符的额外空间。令人惊叹的谢谢