Mar*_*les 0 uitableview ios uirefreshcontrol swift
当我清除数据源中的所有数据并重新加载tableView时,不再提供pull-to-refresh.如何在空tableView上启用pull-to-refresh?
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
}
}
Run Code Online (Sandbox Code Playgroud)
就我而言,我只需要启用弹跳:
self.collectionView.alwaysBounceVertical = YES;
默认NO.如果是,则弹跳为是,即使内容小于边界,也允许垂直拖动
| 归档时间: |
|
| 查看次数: |
2870 次 |
| 最近记录: |