2014-12-06 36 views
0

我試圖實現兩件事情酥料餅的寬度:改變一個在其表視圖

要更改酥料餅的細胞數目的高度,我的靜態表視圖(工作)。

但是,可以使用故事板構建器來配置彈窗寬度。

- (void)viewDidLoad 
{ 
    CGRect popoverBounds = self.view.frame; 

    [self.tableView sizeToFit]; 

    CGRect newBounds = self.tableView.bounds; 
    newBounds.size.width = popoverBounds.size.width; 
    self.tableView.bounds = newBounds; 

    self.preferredContentSize = self.tableView.contentSize; 
} 

當前,這會將彈出窗口設置爲表視圖的寬度。

enter image description here

回答

1

問題是這樣的線內:

self.tableView.bounds = newBounds; 

您更改,而不是框架的內部邊界,你需要使用:

self.tableView.frame = newBounds; 
相關問題