ios - 如何在应用程序快速启动时取消选择 uitableview 单元格

标签 ios swift

这是我的代码

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    tableView.deselectRowAtIndexPath(indexPath, animated: true)
    let key = sortedKeys[indexPath.row]
    if (selectedTypes!).contains(key) {
        selectedTypes = selectedTypes.filter({$0 != key})
    } else {
        selectedTypes.append(key)
    }

    tableView.reloadData()

}

我正在取消选择第二行的单元格,但它不起作用

最佳答案

SDK 不会在您的应用启动时自动选择所有单元格。

如果所有 tableView 单元格都被选中,这是因为您的代码(或第三方控件或库)中的某些内容而发生的。

此外,当以编程方式选择一行时,didSelectRowAtIndexPath 不会被调用。它仅在用户选择一行时调用,因此您希望可行的方法不会自动取消选择任何选定的行。

关于ios - 如何在应用程序快速启动时取消选择 uitableview 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34469261/

相关文章:

ios - 如何在 MKAnnotationView 图像上注册 Tapgesture?

swift - 每次加载 iAd 横幅时,iAd 横幅会抖动/改变场景大小。

ios - touchesBegan 不调用容器 View Controller

ios - 在模拟器和本地设备上获取不同的时间格式 - Swift iOS

ios - 克隆 UIImageView

ios - 选项卡式应用程序(模板),需要一个 Controller 来拥有静态 TableView

ios - 学习 iOS MapKit - 来自 NSDictionary 的 map 上的多个图钉

iphone - 如何在 objective c 的 facebook 组上传图片

ios - 使用 Alamofire 更改标签

arrays - 观察对象列表更新