ios - 如何通过单击 UITableView 的上一个单元格来解锁下一个单元格?
解决方案
有一个包含未锁定行索引的数组。
var unlockedRows: [Int] = [1]
现在您可以检查该行是否已解锁或不在didSelectRowAt
委托中。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if unlockedRows.contains(indexPath.row) {
let nextIndex = indexPath.row + 1
if nextIndex < numberOfRows { //Use your variable that gives total number of rows here instead of numberOfRows
unlockedRows.append(indexPath.row + 1)
// Do other stuff like removing the locked icon of the next cell
}
return true
}
// Display row locked message?
return false
}
推荐阅读
- javascript - 如何找到数组对象中的近距离,并选择近距离并提取对象
- ocaml - 我无法安装任何 ocaml 模块
- c# - Visual Studio网站如何在表格中获取没有时间的日期数据类型
- typescript - 扩展联合类型
- c++ - 如何通过 C++ 中的函数返回初始化静态类变量?
- python - 如何处理 IndentationError: 非空白引起的意外缩进?
- python - 从 docker 中的 pipfile.lock 安装时出错
- java - 如何从文本文件读入对象数组
- javascript - React-redux 组件在来自 reducer 的异步 saga 调用后更新状态属性
- appium - 在 appium java client 7.0.0 中是 driver.pressKeyCode(AndroidKeyCode.HOME); 已弃用,要改用什么?