【发布时间】:2015-10-22 23:08:55
【问题描述】:
我正在尝试在单元格的 setProperty 中访问 TableViewCell 的高度。
我正在通过 xib 创建单元格,然后根据 heightForRowAtIndexPath 中返回的值更改高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 200;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
RightGuideCell* cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
cell.ticks = @[@"1",@"1",@"1",@"1",@"1",@"1",@"1"];
return cell;
}
这是我单元格中的属性。
- (void)setTicks:(NSArray *)ticks {
_ticks = ticks;
CGFloat height = self.frame.size.height; //Value is 44 (size in xib)
}
如何在单元格中获得 200(在heightForRowAtIndexPath 中设置)?
【问题讨论】:
-
高度已在 cellForRowAtIndexPath 中计算,因此您可能需要在此之后重新加载单元格。这将获得新的高度,但可能会占用大量资源。
标签: ios objective-c cocoa-touch tableview