swift - 在 iOS 11.4 中使用 MKSlidingTableViewCell 为单元格动画创建多个单元格对象时崩溃

标签 swift ios11

我正在使用 MKSlidingTableViewCell 制作单元格动画。但是,当尝试在 iOS 11.4 中创建多个单元格对象时,App 会崩溃,但它在 iOS 10 中运行良好。由于未捕获的异常 'NSInternalInconsistencyException',类似 Terminating app 的崩溃消息,原因:'试图为同一索引路径使多个单元格出队,这是不允许的。如果您确实需要出列比 TableView 请求的更多的单元格,请使用 -dequeueReusableCellWithIdentifier: 方法(没有索引路径)。单元格标识符:AllItemsCell,索引路径:{length = 2, path = 0 - 0}'

下面是我的代码。请帮忙。

        let cell : MKSlidingTableViewCell? = (tableView.dequeueReusableCell(withIdentifier: "container", for: indexPath) as? MKSlidingTableViewCell)

        let cellForeground : AllItemsCell? = (tableView.dequeueReusableCell(withIdentifier: "AllItemsCell", for: indexPath) as? AllItemsCell)

        let cellBack : AllItemsCell? = (tableView.dequeueReusableCell(withIdentifier: "backgroundcell", for: indexPath) as? AllItemsCell)

        cell?.foregroundView = cellForeground
        cell?.drawerView = cellBack
        cell?.drawerRevealAmount = 555

最佳答案

根据crash你要改这个

let cell : MKSlidingTableViewCell? = (tableView.dequeueReusableCell(withIdentifier: "container", for: indexPath) as? MKSlidingTableViewCell)

let cell : MKSlidingTableViewCell? = (tableView.dequeueReusableCell(withIdentifier:"container") as? MKSlidingTableViewCell)

//

对剩下的 2 个做同样的事情

关于swift - 在 iOS 11.4 中使用 MKSlidingTableViewCell 为单元格动画创建多个单元格对象时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51477234/

相关文章:

ios - 禁用 24 小时时间的 swift iPhone 设置会导致错误

ios - Swift:Apple Mach-O 链接器 (id) 错误 - Xcode 8.3

uibarbuttonitem - BarButtonItems 和标题未出现在 iOS 11 中

gesture - iPhone X 向上滑动切换应用激活屏幕底部的按钮

ios - 为什么在 iOS 11 中,我的 UIApplicationState 显示为非事件状态而不是事件状态?

ios - UICollectionView 不保留 UITextfield 输入

json - 是否可以将单级 JSON 解码为 2 个独立的模型?

ios - CollectionView中的程序化搜索栏实现问题

Swift 4 TIC SSL 信任错误

ios - 以编程方式从一个 View Controller 切换到另一个