[英]Pull-to-refresh does not work on empty TableView
當我從數據源中清除所有數據並重新加載tableView時,“刷新到刷新”不再可用。 即使在空的tableView上,如何啟用“拉動刷新”功能?
override func viewDidLoad() {
super.viewDidLoad()
...
// Pull to refresh for iPhone
refreshControl?.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
tableView.tableFooterView = UIView(frame: CGRectZero) // To remove separator line on empty cells
tableView.estimatedRowHeight = Constants.DetailTableView.estimatedRowHeight
tableView.rowHeight = UITableViewAutomaticDimension
setupRefreshControl()
}
private func setupRefreshControl() {
// If on iPhone, List becomes the pull-to-refresh handler and the delegate
if UIScreen.mainScreen().traitCollection.horizontalSizeClass == .Compact {
SyncService.shared.delegate = self
refreshControl?.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
refreshControl?.tintColor = UIColor.whiteColor()
} else {
// Otherwise disable the refresh control in List
refreshControl = nil
}
}
就我而言,我只需要啟用反彈功能:
self.collectionView.alwaysBounceVertical = YES;
默認編號 如果是,並且反彈為是,即使內容小於界限,也允許垂直拖動
在表刷新功能中,我實際上具有顯示一些“空表”視圖的代碼,以提醒用戶該表視圖為空,並且該視圖位於該表視圖的視圖上方,因此阻止了交互。 我修復了視圖的圖層,現在可以使用了。 因此,如果您在問題中遇到問題,只需檢查某個視圖是否與您的表視圖不重疊,這就是我的情況。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.