2014-01-07 59 views
1

我有一個UITableViewController與底部的UIView。 (使用故事板)。我的UIView設置爲隱藏,然後通過單擊按鈕更改狀態。首先,我試圖使用self.concluidoView.frame = CGRectMake(0, 0, 320, 50);來調整IBAction(buttonClick)上UIView的大小(基本上增加高度),但是UIView正在消失。現在UITableView擴展子視圖後不夠滾動

,它正確地用下面的代碼裏面IBAction擴大UIView

[UIView animateWithDuration:1.0 
        animations:^{ 
         CGRect frame = self.concluidoView.frame; 
         frame.size.height += 100.0; 
         self.concluidoView.frame = frame; 

        } 
        completion:^(BOOL finished){ 
         // complete 

        }]; 

的問題是,我的UITableViewController沒有滾動足夠的新的大小,因爲UIView是我tableView的最後一個項目。

我已經嘗試了幾件事情來解決這個問題,包括手動嘗試調整tableview以將其高度增加到UIView增加的相同值。我用下面的代碼:

CGRect tableFrame = self.tableview.frame; 
     tableFrame.size.height += 100; 
     self.tableView.frame = tableFrame; 
     [self.tableview layoutIfNeeded]; 

tableview的滾動能力爲這個代碼後實際更小。我想調整tableview並允許手動滾動,因爲我知道我的subview會增加多少或自動增加。

回答

1

如果你改變了UITableView的框架,你所要做的就是讓它最有可能在屏幕外展開。你想要做的是得到表格視圖來識別UIView更大。我假設這個UIView是你的UITableViewtableFooterView。試着做以下幾點:

UIView *footerView = self.tableView.tableFooterView; 
self.tableView.tableFooterView = nil; 
self.tableView.tableFooterView = footerView; 

這將迫使UITableView重新審視頁腳視圖的大小。之前更改頁腳視圖的大小時,我不得不這樣做。

+0

完美!這樣做的工作,我有我的'UIView'在'@屬性',所以我只是'tableFooterView'分配給它。謝謝。 – Jorge