我在一个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;
}发布于 2014-08-18 05:57:17
我假设您希望这个自定义分隔符完全位于两个单元格之间?
如果是这样,那么您基本上需要首先设置tableview分隔符样式,如下所示
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];然后,您必须在表视图单元格中包含足够的空间,以容纳separator.You可以增加每个单元格的高度,或者使分隔符更小以修复重叠。这些更改将发生在分隔符上的initWithFrame或表视图的cellWithHeight中。
https://stackoverflow.com/questions/25355546
复制相似问题