细胞分离重叠重叠细胞iOS

时间:2014-08-18 02:20:15

标签: ios tableview

我在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;
}

1 个答案:

答案 0 :(得分:0)

我假设你想要在两个单元格之间完全放置这个自定义分隔符?

如果是这样,那么你基本上可以首先设置tableview分隔符样式,如图所示

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

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

的cellWithHeight中发生