问题描述
我一直试图找出代码中的问题,但没有找到解决方案。 我有一个下拉库,用于下拉库是 ios Dropdown 1:https://github.com/AssistoLab/DropDown 在这里,我自定义了 tableViewCell 并添加了一个单选按钮。但是当我尝试重新加载它时,它不会更新其状态,即使在设置状态后它仍然保持不变。
func updateCellBy(text: String,index: Int,isSelected: Bool) {
self.index = index
radioButton.isSelected = isSelected
titleLabel.text = text
checkBoxButtonWidthConstraint.constant = 20
radioButtonLeadingConstraint.constant = 15
}
但是当我滚动这个下拉/tableview 下拉按钮时,状态会得到更新。我仍然在想这有什么问题。测试了上述方法中传入的数据是否正确,但这是正确的。DroppDown image 请注意,此下拉列表位于 collectionViewCell 内,而 collectionViewCell 确实位于视图内。
dropDown.cellNib = UINib(nibName: "TableViewCell",bundle: nil)
dropDown.customCellConfiguration = { [self] (index: Index,item: String,cell: DropDownCell) -> Void in
guard let cell = cell as? TableViewCell else { return }
cell.updateCellBy(text: DropdownArrays.shared.getData()[index],index: index,isSelected: self.cellIndexes.contains(index))
cell.delegate = self
}
dropDown.dataSource = DropdownArrays.shared.getData()
dropDown.reloadAllComponents()
这确实是在重新加载 DropDown 库中的单元
Reloads all the cells.
It should not be necessary in most cases because each change to
`dataSource`,`textColor`,`textFont`,`selectionBackgroundColor`
and `cellConfiguration` implicitly calls `reloadAllComponents()`.
*/
public func reloadAllComponents() {
dispatchQueue.executeOnMainThread {
self.tableView.reloadData()
self.setNeedsUpdateConstraints()
}
}
但单元格数据没有更新。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)