2012-03-02 41 views
1

我有一个使用UITableViewStyleGrouped初始化的UITableView。它包含一个组和一个页脚。我正在页脚高度前面遇到不必要的水平线。如果我将页脚设置为隐藏,则线条(和页脚)消失。在以下示例中,页脚高度设置为144px。我看过这个问题的例子,设置一个透明页脚可以解决问题,但是我不能使用这个黑客,因为我需要一个页脚。使用页脚的UITableView底部不需要的水平线

这里有两个例子。两者都使用单节和页脚:

enter image description here

enter image description here

页脚是非常简单的:

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 
{ 
    //Footer 
    UIView *footer = [[UITableView alloc] init]; 
    [footer.layer setBorderColor: [[UIColor clearColor] CGColor]]; //Has no effect 
    [footer.layer setBorderWidth:0]; //Has no effect 
    //[footer.layer setHidden:YES]; //Hides entire footer and lines 
    footer.backgroundColor = [UIColor clearColor]; 
    UIButton *button = [ComponentFactory makeForgottenPasswordButton]; 
    [footer addSubview:button]; 
    return footer; 
} 

我试图隐藏在表视图分隔符:

self.tableView.separatorColor = [UIColor clearColor]; //Has no effect 
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; //Has no effect 
self.tableView.backgroundColor = [UIColor clearColor]; 

部分和行:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the section. 
    return 2; 
} 

他们从哪里来,我怎么能隐藏它们?

+0

有一次我想问的问题,为什么使用tableview的登录目的? – Rupesh 2012-03-05 05:57:08

+0

它在iPhone应用程序中很常见。例如Soundcloud – Undistraction 2012-03-05 09:56:10

+0

这将是简单易用的标签和文本框。 – Rupesh 2012-03-05 09:59:14

回答

0

所以我会检查两件事情:

1)什么是您的tableView的背景颜色?

2)您通过数据源提供了多少部分?

至于(1),用于分组式UITableView的背景默认为您所看到的背景。举个例子,在iPhone上加载联系人应用程序并选择一个联系人。您会在上面显示的背景顶部看到各个部分。如果您需要其他颜色,请为tableView的.backgroundColor属性提供UIColor或其他颜色。

更新:它也看起来像你有“细胞分离器”的原因实际上是因为你没有提供正确的细胞高度,所以你的文本基本上流血到下一个单元格。尝试将单元格高度设置为75.0之类,看看是否能解决您的问题。 75可能太大,但它应该得到重点。

+0

谢谢。已更新我的问题以澄清。如果tableView。backgroundColor设置为[UIColor clearColor]我失去了条纹,但保留了不需要的水平线,并且我的委托返回了1的部分数。 – Undistraction 2012-03-05 10:03:04

+0

看到我编辑的回复 – jmstone617 2012-03-05 21:03:17

+0

谢谢,但没有区别。 – Undistraction 2012-03-06 09:29:29