indexPathForSelectedRow返回Section中的索引路径

问题描述

我对用户单击我的TableView时返回的IndexPath有疑问。

我有一个对象数组,可以循环遍历并传递到字典中,如下所示

terms = Term.terms()

// Create the terms dictionary
for term in terms {
  let termKey = String(term.Abbreviation.prefix(1))
  if var termValues = termsDictionary[termKey] {
    termValues.append(term)
    termsDictionary[termKey] = termValues
  } else {
    termsDictionary[termKey] = [term]
  }
}

//get the section Titles from the dictionary's ket and sort them in ascending order
termsSectionTitles = [String](termsDictionary.keys)
termsSectionTitles = termsSectionTitles.sorted(by: { $0 < $1 })

到目前为止一切都很好。然后,当用户单击单元格时,这些控件将正确填充表格视图。然后,我需要找到所选单元格的对象。

例如,用户选择B部分中的第三个单元格,它返回2作为索引路径。我知道为什么,但这与我需要的对象不符。

是否有一种获取单元格的索引路径而无视标题的方法?

guard
  segue.identifier == "ShowDetailSegue",let indexPath = tableView.indexPathForSelectedRow,let detailViewController = segue.destination as? DetailViewController
  else {
    return
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...