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