当我清除数据源中的所有数据并重新加载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
}
}发布于 2016-01-25 09:04:02
在表刷新函数中,我实际上有代码来显示一些“空表”视图,以提醒用户tableview是空的,并且该视图位于tableview视图的上方,从而阻止了交互。我修复了视图的层次,现在它开始工作了。因此,如果您在问题中遇到了这个问题,只需检查某个视图是否与表视图重叠,这就是我的情况。
发布于 2017-01-23 19:13:44
在我的例子中,我只需要启用弹跳:
self.collectionView.alwaysBounceVertical = YES;
默认数字。如果是和反弹是肯定的,即使内容小于界限,允许垂直拖动。
https://stackoverflow.com/questions/34810132
复制相似问题