2013-10-16 42 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

相關問題