首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拖放刷新不适用于空的TableView。

拖放刷新不适用于空的TableView。
EN

Stack Overflow用户
提问于 2016-01-15 11:33:02
回答 2查看 3.8K关注 0票数 1

当我清除数据源中的所有数据并重新加载tableView时,就不再可用了。即使在空的tableView上,我也如何启用拉到刷新?

代码语言:javascript
复制
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
    }
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-25 09:04:02

在表刷新函数中,我实际上有代码来显示一些“空表”视图,以提醒用户tableview是空的,并且该视图位于tableview视图的上方,从而阻止了交互。我修复了视图的层次,现在它开始工作了。因此,如果您在问题中遇到了这个问题,只需检查某个视图是否与表视图重叠,这就是我的情况。

票数 3
EN

Stack Overflow用户

发布于 2017-01-23 19:13:44

在我的例子中,我只需要启用弹跳:

self.collectionView.alwaysBounceVertical = YES;

默认数字。如果是和反弹是肯定的,即使内容小于界限,允许垂直拖动。

票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34810132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档