2010-04-15 88 views
1

我遇到了一个问题,至于我不知道如何解决。任何人都可以在盒子外面思考并指向正确的方向吗?我会非常感谢!UITableView背景问题

问题所在。
我有一个UITableView包含第一行至始终是相同的(重复背景的空行)下一行是动态数据行的bounch。我已在我的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例子。 事情是我不想有最后一个datarow下的黄色背景,我想包含我对细胞有相同的白色。

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

这应该是白色作为细胞。不是黄色。

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

感谢ü您的时间。 Regards

回答

2

找到结果。只是简单地添加了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]; 
0

如果你想达到这个目标,你必须用空单元格填充表格视图的底部,并为那些白色着色。在底部弹跳时,你仍然会遇到同样的问题。问题是黄色单元格不存在,所以它们使用表格视图的背景颜色。

另外,那个黄色和那个绿色真的是不一起去。

+0

不要担心黄色,因为我写的只是示例颜色。我和你想的一样,其实...... – f0rz 2010-04-15 08:40:00