2013-07-25 84 views
2

我已經通過屬性設置的tableView自定義頁腳:爲什麼tableView不允許滾動查看footerView?

​​

中的tableView填充屏幕幾乎全高度,所以只有1/3的頁腳的一部分是在底部可見。我已禁用彈跳,我不能滾動tableView到底部看footerView。如果彈跳啓用,那麼我可以彈跳並看到表格頁腳,但表格在彈跳後返回到相同的位置。它看起來像tableView內容大小不包括我的footerView,這就是爲什麼我無法滾動。 Ay的想法如何解決這個問題?

+1

你設置它的頁腳視圖的幀(尤其是高度)之前設置爲表的頁腳?同時嘗試在'viewWillAppear'中設置頁腳並查看會發生什麼 –

+0

是的,我已將其框架設置爲包含兩個操作按鈕。通過NSLog檢查其框架,並添加紅色bg顏色以查看框架大小。 – Centurion

+0

檢查表格視圖的框架並確保它不大於屏幕。 –

回答

1

JoshHinman是正確的(「檢查桌子視圖的框架並確保其不大於屏幕。」)。我通過將MyViewController.view添加到AnotherViewController.view中作爲子視圖來重用在AnotherViewController中包含tableView的MyViewController。由於AnotherViewController.view包含一些徽標圖像,因此MyViewController.view.tableView被推到底部。當他指出,問題是我已經推動tableView太多:)

0

你必須與該數據源方法設置的頁腳

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 

另外,還要確保實現代碼如下的框架是satisfyiable的頁腳在視圖中

編輯這個方法有助於設定頁腳可見到每個部分,因此如果您想在檢查方法中返回的部分後將頁腳設置爲最後一次查看。

還有提問者intented這個工作對我來說

UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 40)]; 
[view1 setBackgroundColor:[UIColor redColor]]; 

[self.view addSubview:view1]; 
[self.table setTableFooterView:view1]; 

等檢查[self myCustomFooterView];

+3

如何添加頁腳有兩種方法。您建議的方式允許爲每個部分添加頁腳。可以將它添加到最後一節,但需要一些檢查。另一個更清晰的方法是通過設置tableFooterView屬性爲整個表添加頁腳。 – Centurion

+0

@Centurion:對,我會更新他的詳細回答 –

+0

不過,我寧願使用tableFooterView屬性來設置footerView。 – Centurion

0

還寫下面的代碼,之後您將頁腳UITableView的:

CGSize wholesize = self.tableView.contentSize;  
wholesize.height = self.tableView.contentSize.height + self.tableView.tableFooterView.frame.size.height; 

self.tableView.contentSize = wholesize; 
[tableView setContentOffset:CGPointMake(0, tableView.contentSize.height) animated:YES]; 
self.tableView.tableFooterView.userInteractionEnabled = YES;