由于未捕获的异常终止应用' NSInternalInconsistencyException',原因:'尝试删除第100部分,但更新前只有7个部分' ***首先抛出调用堆栈:
我试图制作可折叠的TableView WithAnimation.From Header确实点击了它将调用切换部分的方法。我的工作基于它是选择还是不选择bool值。
class ExploreLocallyVc: UIViewController {
var headerViewMain = HeaderView()
@IBOutlet weak var tableView: UITableView?
var ArrayOfCollapsable : [Int:Bool]? = [:]
var prevIousSelection : Int? = 100
override func viewDidLoad() {
super.viewDidLoad()
tableView?.estimatedRowHeight = 80
tableView?.rowHeight = UITableViewAutomaticDimension
tableView?.sectionHeaderHeight = 60
tableView?.separatorStyle = .none
}
}
extension ExploreLocallyVc:UITableViewDelegate,UITableViewDataSource
{
func numberOfSections(in tableView: UITableView) -> Int
{
return 7
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
if (ArrayOfCollapsable?[section] == true) {
print("yes")
return 4
}
else
{
print("No")
return 0
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "q", for: indexPath)
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
headerViewMain = (Bundle.main.loadNibNamed("HeaderView", owner: self, options: nil)![0] as? HeaderView)!
headerViewMain.titleLabel?.text = "\(section)"
if (ArrayOfCollapsable?[section] == true) {
headerViewMain.arrowLabel?.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
}
headerViewMain.section = section
headerViewMain.delegate = self
return headerViewMain
}
}
extension ExploreLocallyVc:HeaderViewDelegate
{
func toggleSection(header: HeaderView, section: Int)
{
if (ArrayOfCollapsable?[section] == true) {
print("yes")
ArrayOfCollapsable?[section] = false
}
else
{
print("No")
ArrayOfCollapsable?[section] = true
ArrayOfCollapsable?.updateValue(false, forKey: prevIousSelection!)
}
tableView?.reloadSections(NSIndexSet(index: section) as IndexSet, with: .automatic)
prevIousSelection = section
print(ArrayOfCollapsable!)
}
}
答案 0 :(得分:1)
我先重新加载上一节,然后重新加载更改的部分
<script strong textsrc="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/mvc/5.2.3/jquery.validate.unobtrusive.min.js"></script>
<script src="@Url.Content("~/scripts/umbraco-starterkit-app.js")"></script>
<script src="@Url.Content("~/scripts/home.js")"></script>