我有自定义标题的tableview。并且uitableview行单元格具有刷新按钮,该按钮将调用API并重新加载发送方单元格。但是,每当刷新完成时,节标题就会消失。
extension AccountViewController: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 {
return 1
} else {
return platforms.count - 1
}
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "BalanceHeaderCell") as? BalanceHeaderCell
if self.currentUser != nil {
self.saveUserDefault(item: currentUser?.balance ?? "", key: Account.accountBalanceRecord)
cell?.headerRefreshButton.tag = section
cell?.headerRefreshButton.addTarget(self, action: #selector(refreshAccountBalanceInfo), for: UIControlEvents.touchUpInside)
cell?.set(user: self.currentUser!)
}
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "PlatformHeaderCell") as? PlatformHeaderCell
return cell
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "BankCardsCell", for: indexPath) as? BankCardsCell
cell?.setCell(bankCount: self.bankCount)
return cell!
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "PlatformListCell", for: indexPath) as? PlatformListCell
cell?.set(platforms: platforms[indexPath.row])
cell?.platformRefreshButton.tag = indexPath.row
cell?.platformRefreshButton.addTarget(self, action: #selector(refreshPlatformBalanceInfo), for: UIControlEvents.touchUpInside)
return cell!
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return 73
} else {
return 40
}
}
你有什么建议?