0
我已经创建了一个UITableViewCell派生类,它调整自己的大小以显示在缩进级别。我曾尝试使用在ViewControllers的cellForRowAtIndexPath以下设置indentationLevel和indentationWidth:调整UITableViewCell的大小
cell.indentationLevel = [[item objectForKey:@"indent"] intValue];
cell.indentationWidth = CELL_INDENT_SIZE;
这本身不缩进细胞,所以我使用了的UITableViewCell以下layoutSubviews:
-(void)layoutSubviews {
CGFloat indentSize = (self.indentationLevel - 1) * self.indentationWidth;
CGRect r = containerView.frame;
containerView.frame = CGRectMake (r.origin.x + indentSize, r.origin.y, r.size.width - indentSize, r.size.height);
DLog(@"frameRect : %f, %f, %f, %f, %f",indentSize, r.origin.x, r.origin.y, r.size.width, r.size.height);
[super layoutSubviews];
}
这对于初始布局可以很好地工作,但是当选中单元格时,它会从新维度重新计算自己,并在每次选择单元时有效缩小单元格。
如何调整此单元格的大小,使其不会更改布局。
为什么默认缩进不适合你?我认为这将更加重要。 – TechZen 2010-05-12 22:56:50