我正在使用 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/