【问题标题】:Background problem on UITableViewUITableView的后台问题
【发布时间】:2010-04-15 07:28:33
【问题描述】:

我遇到了一个问题,我不知道如何解决。任何人都可以跳出框框思考并指出正确的方向吗?我会非常感激的!

问题。
我有一个包含第一行的 UITableView 总是相同的(具有重复背景的空行)下一行是动态数据行的集合。我在 IBuilder 中的 UITableView 上设置了黄色背景,我的单元格(第一行除外)有白色背景和代码:

     UIView* backgroundView = [ [ [ UIView alloc ] initWithFrame:CGRectZero ] autorelease ];
 backgroundView.backgroundColor = [UIColor colorWithRed: 0.96078431372549 green: 0.96078431372549 blue: 0.96078431372549 alpha: 1.0];
 cell.backgroundView = backgroundView;
 for ( UIView* view in cell.contentView.subviews ) 
 {
  view.backgroundColor = [ UIColor clearColor ];
 }

alt text http://rabbitrun.karatefors.org/img1.png

示例黄色背景,我只想显示在顶部。正如您在下面看到的 img 示例。 问题是我不想在最后一个数据行下有黄色背景,我想在单元格上包含相同的白色。

alt text http://rabbitrun.karatefors.org/img2.png

这应该是白色的单元格。不是黄色的。

alt text http://rabbitrun.karatefors.org/img3.png

感谢您的宝贵时间。 问候

【问题讨论】:

    标签: iphone cocoa-touch uitableview uikit


    【解决方案1】:

    找到解决方案。只是简单地在 tableview 的顶部添加了一个视图。

        UIView *topview = [[[UIView alloc] initWithFrame:CGRectMake(0,-480,320,480)] autorelease]; 
        topview.backgroundColor = [UIColor colorWithRed:71.0/255.0 green:71.0/255.0 blue:71.0/255.0 alpha:1];
        [self.tableView addSubview:topview];
    

    【讨论】:

      【解决方案2】:

      如果您想实现这一点,您必须用空单元格“填充”表格视图的底部,并将这些单元格着色为白色。在底部弹跳时,您仍然会遇到同样的问题。问题是黄色的单元格不存在,所以它们使用表格视图的背景色。

      另外,那个黄色和那个绿色真的不配。

      【讨论】:

      • 不要担心黄色,因为我写的只是示例颜色。其实我的想法和你一样……
      猜你喜欢
      • 1970-01-01
      • 2020-04-10
      • 2013-12-19
      • 2012-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多