【问题标题】:Problem with Custom accessoryView in UITableViewUITableView 中自定义附件视图的问题
【发布时间】:2011-08-23 03:26:41
【问题描述】:

我有两个带有以下声明的表视图。

cAboutUs = [[UITableView alloc] initWithFrame:CGRectMake(85, 272, 227, 30)];

ctableView = [[UITableView alloc] initWithFrame:CGRectMake(85, 302, 227, 100)];    

当我尝试使用以下代码添加自定义附件视图时,两者都位于单元格中的不同位置。 (在 cAboutUs 中,与 ctableView 单元格附件相比,它更向左(x))

UIImage *image = [UIImage imageNamed:@"bullet.png"];

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame;

[button setBackgroundImage:image forState:UIControlStateNormal];
cell.accessoryView = button;

我也尝试过使用

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator

它显示正确且对齐良好。

请帮我解决这个错误。

【问题讨论】:

  • 两个table view使用同一张图片,怎么会出问题。
  • 你是否同时显示两个表格视图?

标签: iphone ios4 uitableview


【解决方案1】:

它通过将 cAboutUs 表格单元格的高度增加到 40 来解决。奇怪但没有解决的原因。

【讨论】:

    【解决方案2】:

    检查两个表格视图中单元格的高度。

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    // Make sure height for the cells is the same
    }
    

    【讨论】:

      猜你喜欢
      • 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
      相关资源
      最近更新 更多