【发布时间】:2012-03-21 01:37:31
【问题描述】:
我有一个用 UITableViewStyleGrouped 初始化的 UITableView。它包含一个组和一个页脚。我遇到了在页脚前面重复页脚高度的不需要的水平线。如果我将页脚设置为隐藏,线条(和页脚)就会消失。在以下示例中,页脚高度设置为 144 像素。我已经看到设置透明页脚解决问题的这个问题的示例,但是我不能使用这个 hack,因为我需要一个页脚。
这里有两个例子。两者都使用一个节和一个页脚:
页脚很简单:
-(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;
}
它们来自哪里,我该如何隐藏它们?
【问题讨论】:
-
有一次我想问一下,为什么要使用tableview来登录?
-
它在 iPhone 应用程序中很常见。例如 Soundcloud
-
这将是简单易用的标签和文本字段。
-
是的,不过我用的是桌子。
-
我没有使用 xib,如果您阅读问题,您会看到我已经在设置分隔符样式:tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
标签: iphone uitableview ios5 footer