【问题标题】:custom UITableViewCell height width provies wrong value.自定义 UITableViewCell 高度宽度提供了错误的值。
【发布时间】:2012-11-29 09:21:09
【问题描述】:

我在.xib中设计了UITableViewCell,它的高宽分别是:

从 Xcode 中检索 -> 显示尺寸检查器。

Width : 358   Height : 562 

TableView 委托:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return 800;
 }

我在尝试什么?

在下面的方法中,我试图找到单元格的宽度和高度,以便在单元格中画一条垂直线。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:   (NSIndexPath *)indexPath 
{
  /* FINDING THE WIDTH AND HEIGHT */
   my Custom Cell instance say : cell

   cell.contentView.bounds.size.width   Give  me the value -> 320,
   cell.contentView.bounds.size.height  Gives me the value -> 44,
}

问题?..

如何获得自定义单元格的正确高度/宽度?​​

如果我的理解有误,请告知?

【问题讨论】:

    标签: iphone objective-c cocoa-touch ios4


    【解决方案1】:

    您需要覆盖-tableView:willDisplayCell:forRowAtIndexPath:。在这种方法中,表格视图已经设置了正确的尺寸。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多