gpt4 book ai didi

uitableview - Swift - 搜索时禁用 refreshControl

转载 作者:搜寻专家 更新时间:2023-10-30 22:12:07 25 4
gpt4 key购买 nike

在搜索过程中,我想禁用下拉刷新机制。所以我禁用了刷新控件并将其删除。但是当下拉刷新时会调用 beginRefresh 方法,单元格会保持下拉状态 2 秒,就像刷新一样。

func searchBarShouldBeginEditing(searchBar: UISearchBar) -> Bool {
resultSearchController.searchBar.selectedScopeButtonIndex = 0
refreshControl!.enabled = false
refreshControl?.removeFromSuperview()
return true
}

最佳答案

如果要在 UITableView 的顶部创建或删除刷新控件,请使用这两个函数。

func createRefreshControl() {
// Create RefreshControl and add to tableView
self.refreshControl = UIRefreshControl()
self.refreshControl!.attributedTitle = NSAttributedString(string: " ↓ Refresh ↓ ")
self.refreshControl!.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
}

func deleteRefreshControl() {
// delete RefreshControl
self.refreshControl = nil
}

关于uitableview - Swift - 搜索时禁用 refreshControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30581534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com