gpt4 book ai didi

ios - 重新加载除第一和第二之外的所有部分

转载 作者:搜寻专家 更新时间:2023-11-01 06:14:27 25 4
gpt4 key购买 nike

我有包含多个部分的 Tablview。

第一部分-它包含搜索文本框
第二部分 - 它包含 UIView
其他部分-我想在搜索时重新加载的这个部分。

更新
我设置了 countdic 和 tableview 如下:-
<强>1。设置计数

self.countDic.updateValue(1, forKey: "0")// this is for First section
self.countDic.updateValue(0, forKey: "1")//this is for second section
for i in 0..<arra1.count {
self.countDic.updateValue(array.count, forKey: "\(i + 2)")//[index : arraylist.count]
}


2.这是我的表格 View 设置

 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return countDic["\(section)"]!
}

func numberOfSections(in tableView: UITableView) -> Int {
return countDic.count
}


3.我在这里重新加载 tableview
这是来自 shouldChangeCharactersIn 的 UITextfield

 let indexSet = IndexSet(integersIn: 2..<self.TblView.numberOfSections)
self.TblView.reloadSections(indexSet, with: .bottom)

但它使应用程序崩溃并出现错误:

** reason: 'attempt to insert section 3 but there are only 3 sections after the update' **

谁能建议怎么做?

最佳答案

这是 swift 。

  • NS(Make)Range 不合适
    (顺便说一下,NSMakeRange 的第二个参数是长度 而不是结束索引)
  • NSMutableIndexSet 不合适

使用 Swift 功能:

let indexSet = IndexSet(integersIn: 2..<self.countDic.count)
self.TblView.reloadSections(indexSet, with: .bottom)

关于ios - 重新加载除第一和第二之外的所有部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48078158/

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