2012-08-17 72 views
0

我有一個單元格的表格視圖,但顯示的單元格邊框填充了整個屏幕。如果只有一個單元格,UITableView爲什麼會爲所有這些單元格繪製單元格邊框?我希望我的表的行爲與股票鬧鐘應用程序中的表視圖相同 - 它只吸引表格中的單元格。任何想法如何做到這一點?iOS:只有一個表格單元,但屏幕充滿單元格邊框

回答

2

嘗試設置表格頁腳視圖

tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; 
+1

請確保釋放,除非它在ARC上。 – 2012-08-17 14:46:25

2

試試這個代碼;

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)]; 
    view.backgroundColor = [UIColor whiteColor]; 
    return view; 
} 
+0

這一個肯定也有效,但我檢查了CSmith的第一個答案,因爲它更短。謝謝 – inorganik 2012-08-17 14:46:43

+0

@inorganik沒問題,祝你好運! ; - ] – Nathan 2012-08-17 14:47:28