2013-02-28 70 views
3

我已經創建了一個分割視圖控制器,我想減少表視圖的大小,但它已經建立在tableView控制器,所以有什麼辦法來改變表的大小從代碼意味着我只有4行,它得到splitViewController中的所有我想減少tableViewController的大小。 在我的根控制器中,它是tableViewController,所以任何方式來解決這個問題。如何更改tableView控制器中的tableView的大小

我還附加了表格圖像下方的圖像,因爲它只有三條記錄,所以我希望它只能顯示三行,它也顯示空行。

enter image description here

回答

1

您可以設置每行的高度UITableView中的這種委託方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; 

一旦您設置的高度,你必須reload你的表。

編輯:

- (void) viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.tableView.tableFooterView = [[[UIView alloc] init] autorelease]; 
} 
+0

能否請您解釋一下如何解決這個問題,並且將它解決這個問題 – 2013-02-28 10:29:11

+0

它只是起了變化單元格高度不表hieght – 2013-02-28 10:31:17

+0

@NaziaJan:要刪除這些額外的白線哪些來了? – Rushi 2013-02-28 10:32:36

0

您可以添加該代碼。這將不會受到此

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //Set height according to your condition 
    if (indexPath.row == 0) 
    { 
    } 
    else 
    { 
    } 
} 

顯示在您UITableView

- (void) addFooter 
{ 
    UIView *v = [[UIView alloc] initWithFrame:CGRectZero]; 

    [self.myTableView setTableFooterView:v]; 

    [v release]; 
} 

您還可以設置你的行高度多餘的線條,然後你可以重新載入你UITableView

[tableview reloadData]; 

編輯:致電功能addFooter in - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

,你可以添加這也

- (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { 
    // This will create a "invisible" footer 
    return 0.01f; 
} 
+0

在哪裏調用添加頁腳方法和之後的代碼可以我reloadData – 2013-02-28 10:33:11

+0

如果你在委託方法中設置該函數的高度,那麼無需重新加載tableview,只有當你要加載你的tableview的內容,那麼你可以使用從任何功能。 – 2013-02-28 10:41:00