[英]ios:UITableView wont scroll to bottom
我有一個滾動視圖,其中有3個UITableViews
用於分頁。 所有UITableViews
加載更多數據單元。 第一個UITableView
加載的單元格比其他兩個更多。 當查看第一個UITableView
我可以滾動到底部,但是當我滾動到第二個UITableView
並返回到第一個UITableView
我將無法一直向下滾動。 好像我必須調整滾動視圖的大小。 視圖刷新后為什么不能滾動到底部? 任何幫助都會很棒。
*第一個UITableView
在頂部有一個搜索欄。 其他兩個沒有。 我嘗試刪除搜索欄,但仍然出現錯誤。
//Create a frame for each page and add the page to the scroll view
- (void)frameToScrollView{
if (pages!=NULL) {
for (int i = 0; i < pages.count; i++) {
//Get the current view controller
UITableViewController *controller = [pages objectAtIndex:i];
//Create a frame for the current table view controller
CGRect frame = controller.view.frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
controller.view.frame = frame;
//Add the the current table view controller page to the scroll view
[self.scrollView addSubview:controller.view];
}
}
}
設置其他屬性:
//Set the properties for the scroll view
- (void)setScrollViewProperties{
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * pages.count, self.scrollView.frame.size.height);
self.scrollView.contentOffset = CGPointMake(self.scrollView.frame.size.width, 0);
self.scrollView.scrollsToTop = NO;
}
UITableView
是UIScrollView
的子類。 因此,您基本上是將3個滾動視圖添加到一個滾動視圖。 我認為這是不可取的。
我認為這里的問題是設備對哪個scrollView將處理觸摸/拖動事件感到困惑。
如果確實需要使用scrollView進行分頁,建議您創建scrollView,但是為此禁用觸摸事件。 您可以添加按鈕以允許頁面導航(而不是允許用戶左右滑動)。 這樣,您可以確保只有可見的表視圖才能獲取touch / drag事件。
在這里發現了類似的問題: UITableView在某些情況下不會滾動 。
我的第一個UITableView在頂部有一個搜索欄。
在上面的帖子中,他們建議添加[self.tableView setAlwaysBounceVertical:YES];
我對此進行了測試,但無法正常工作。 我把它放在我的視圖中確實為UITableView加載了。
得到它的工作:
(1)單擊“加載更多”單元格並收到信息后,我刪除所有子視圖
(2)然后創建新框架並將其添加回子視圖
(3)最后我重新加載表數據
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.