【发布时间】:2011-06-02 16:36:38
【问题描述】:
我正在尝试使用不同高度的 UITableViewCell 填充 UITableView。我在
中返回正确的尺寸- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
看起来框架以某种方式使用了单元格的高度,但出队的单元格的大小仍然相同。
我也尝试过在单个单元格上使用 setFrame: ,但这仍然没有任何效果。我错过了什么
例如
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (condition 1)
return 60;
else if (condition 2)
return 100;
return 44;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TableViewCell";
TableViewCell *cell = (TableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
【问题讨论】:
标签: ios4 uitableview