2013-04-28 130 views
1

當我設置的tableview的footerView這樣的:如何讓UITableView的FooterView可見?

self.tableView.tableFooterView.frame = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 45.0f); 

然後我cellCount * cellHeight> tableview.frame.size.height。 然後我發現footerView無法顯示。必須拉它顯示的桌面。如何解決它?

self.tableView.tableFooterView = [[UIView alloc] init]; 
self.tableView.tableFooterView.backgroundColor = [UIColor orangeColor]; 
[self.tableView setEditing:YES animated:YES]; 
self.tableView.tableFooterView.frame = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 45.0f); 

//It can't to solve My Problem 
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:9 inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; 
+1

你想讓你的頁腳視圖在* all *時顯示,或者當用戶滾動到表格底部時顯示? – 2013-04-28 07:36:48

+0

謝謝! 我希望頁腳視圖在用戶滾動到表格底部時可見。所有時間:使用heightForFooterInSection委託?或其他方式? – yang 2013-04-28 11:14:04

回答

0

創建footerView(由代碼或在xib)。然後使用以下委託方法:

- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ 
      return footerView.frame.size.height; 
    } 
    - (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ 
      return footerView; 
    } 

在你的情況,你可能不會回來了頁腳的高度。

+0

謝謝!我設置了navigationItem的rightBarbuttonItem來編輯/完成我的tableview(由xib創建)。我想在tableview編輯時顯示footerView,然後在tableView不編輯時隱藏footerView。我知道reloadData可以工作。但它是否有其他解決方法?因爲當我編輯它時,我真的不想更改數據。謝謝! – yang 2013-04-28 11:04:57

相關問題