Swift iOS 13 UITableView选择/取消选择问题
在我的项目UITableView中,它在ios 12及更低版本上运行得非常好,但随着ios 13的新更新,它开始出现多个问题 选择的工作方式是我获取最后一行,但我在代码中为所选行更改了背景,现在我选择的每一行的背景都保持选中状态,而不仅仅是最后一行,并且我设置了只能选择一行 例如,若我在indexPath 3处滚动选中的行,那个么即使我并没有选择它,当我滚动“因为表格每10或15行有90行”时,也会被选中 最后一件可能与之相关的事情是: 我在每一行与谁切换,我做一些动作取决于选择的行,当我选择第一是确定的,但当我取消选择并选择另一个第一个留在记忆中的地方,我不能选择下一个,所以在这一点上没有选择,我不能再选择任何东西 同样,ios 12及更低版本也能正常工作 我怎样才能解决这个问题 这是我代码的一部分:Swift iOS 13 UITableView选择/取消选择问题,swift,uitableview,select,ios13,uiswitch,Swift,Uitableview,Select,Ios13,Uiswitch,在我的项目UITableView中,它在ios 12及更低版本上运行得非常好,但随着ios 13的新更新,它开始出现多个问题 选择的工作方式是我获取最后一行,但我在代码中为所选行更改了背景,现在我选择的每一行的背景都保持选中状态,而不仅仅是最后一行,并且我设置了只能选择一行 例如,若我在indexPath 3处滚动选中的行,那个么即使我并没有选择它,当我滚动“因为表格每10或15行有90行”时,也会被选中 最后一件可能与之相关的事情是: 我在每一行与谁切换,我做一些动作取决于选择的行,当我选择第
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return self.patientData.arrayNames.count
return structuredNames.count;
}
// create a cell for each table view row
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:PatientExercizeCell = self.table.dequeueReusableCell(withIdentifier: "exercizeCell") as! PatientExercizeCell
cell.cellIndex = indexPath.row
cell.exercizeName.text = structuredNames[indexPath.row][1]
cell.appName.text = structuredNames[indexPath.row][0]
cell.dateOfExercize.text = structuredNames[indexPath.row][2] + " " + structuredNames[indexPath.row][3]
if(!listOfNotes.isEmpty){
if(listOfNotes[indexPath.row] != ""){
cell.noteButton.isHidden = false
cell.noteButton.tag = indexPath.row
}else{
cell.noteButton.isHidden = true
}
}
if(fileHandler.listOfFilesFromDevice.contains(fileNames[indexPath.row]) && patientIsSended && !(leftoverFiles.contains(fileNames[indexPath.row].components(separatedBy: ".t")[0]))){
cell.deleteButton.isHidden = false
cell.deleteButton.tag = indexPath.row
}else{
cell.deleteButton.isHidden = true
}
if(GlobalSession.checkedExercises.contains(indexPath.row)){
cell.checkMark.isOn = true
}else{
cell.checkMark.isOn = false
}
return cell
}
// method to run when table view cell is tapped
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
indexPathNumber = indexPath.row
let selectedCell:UITableViewCell = tableView.cellForRow(at: indexPath)!
selectedCell.contentView.backgroundColor = Color().blue()
}
试试这些:
- 禁用多行选择
- 重置
和tableView(ux0:did取消rowat:)
tableView(x0:cellForRowAt:)
再看看这个类似的问题:我认为这是因为细胞的循环行为 我的建议是
您可以在iOS12和iOS13上上传视图的视频记录吗?现在,我将视频放在Dropbox上它被禁用,因为我在情节串连板中选择了单个选择,并且我尝试使用tableView(u:DidDecelRowat:)重置它,但我有一个问题,当我滚动索引重置时,索引只会变为15,例如,在屏幕上可以看到,我在表中有90条记录,但索引变为15,没有进一步的问题。然后,可能是填充
structuredNames
。可能是,不知道,我如何填充它很复杂,但到目前为止我还没有问题,现在它在表中正确显示名称和数据,选择时出现问题,但奇怪的是,我完全没有更改,同一版本的应用程序在ios 12和ios 13上都有,并且在其中一个上运行良好,关于同一个codeiOS 13的其他问题,这是我所说的最糟糕的版本。你能在git上上传一些代码吗?我不能,因为这是我所在公司的一个项目。不同的方法解决了表格选择问题,另一种方法是使用switch,我找到了不同的解决方案