gpt4 book ai didi

ios - UIRefreshControl 旋转太快

转载 作者:行者123 更新时间:2023-11-30 12:26:50 28 4
gpt4 key购买 nike

我想触发refreshControl在tableView从服务器初始化其数据时自动显示,并且我在这个问题上尝试了多种方法

UIRefreshControl - beginRefreshing not working when UITableViewController is inside UINavigationController

refreshControl 确实显示了数据何时初始化,但它旋转得太快(可能是正常速度的 2 倍)。

有谁知道这个问题的原因以及如何解决吗?

最佳答案

这是代码

override func viewDidLoad() {
super.viewDidLoad()
networkManager = BookNetworkManager(userAccount: userAccount)
HUD = JGProgressHUD.standard
refreshControl!.addTarget(self, action: #selector(refreshData), for: .valueChanged)
tableView.tableFooterView = UIView()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
delegate?.setNavgationItem(status: .none)
if !loaded {
tableView.setContentOffset(CGPoint(x: 0, y: -self.refreshControl!.height - self.topLayoutGuide.length), animated: true)
refreshControl!.beginRefreshing()
refreshData()
loaded = true
}
}

func refreshData() {
delegate?.hidePlaceHolder(type: .history)
refreshControl!.attributedTitle = NSAttributedString(string: "刷新数据中")
networkManager.getHistoryBook()
{ (response, errorInfo, books) in
if response == .success {
self.historyBookList = books
self.historyBookList.sort{ $0.returnDateTimeInterval > $1.returnDateTimeInterval }
self.tableView.reloadData()
if books.isEmpty {
self.delegate?.showPlaceHolder(message: "还没有借阅过书籍噢", for: .history)
}else{
self.delegate?.hidePlaceHolder(type: .history)
}
}else {
print(errorInfo?.errorDescription ?? response.rawValue)
self.HUD.show(message: errorInfo?.errorDescription ?? response.rawValue, time: 2)
self.delegate?.showPlaceHolder(message: "出错啦,下拉刷新一下吧?", for: .history)
}
self.refreshControl!.endRefreshing()
self.refreshControl!.attributedTitle = NSAttributedString(string: "下拉刷新数据")
}
}

关于ios - UIRefreshControl 旋转太快,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44087437/

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