2013-10-16 43 views
0

我试图将一个静态的UITableView到一个UIViewController 我现在面临的问题,现在你可以从图像中看到的是,如何调整这个UITableView,以便我可以得到我想要的?

enter image description here

这是一个“普通”模式的UITableView(而不是“分组”) 您可以看到底线(表格结束处)显示正确。但是顶部没有一行(表格开始的地方)。

有没有什么办法可以通过编程方式或通过xcode添加一行,除了在具有灰色背景的UIView中添加1点高度?

感谢

+0

为了使用静态的细胞,我还以为你不得不从对象库中拖动的UITableViewController到画布上。 – bilobatum

+0

我同意你的观点,但我还有其他一些限制,不允许我这样做。 – TypingPanda

回答

1

尝试设置1个像素宽头

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
    return 1; 
} 

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; //It will stretch 
    view.backgroundColor = [UIColor grayColor]; 
} 
+0

谢谢,这实际上工作得很好。大明星给你! – TypingPanda

+0

如果有人正在寻找适合其他分隔符的确切颜色,可以参考这个[什么是默认UITableView分隔符的UIColor?](http://stackoverflow.com/questions/6446279/what-is-the-的UIColor的最 - 缺省 - UITableView的分离器) – TypingPanda

相关问题