ios - 无法将类型 'UITableViewCell' 的值转换为 'SwipeCellKit.SwipeTableViewCell'

标签 ios swift uitableview

我正在尝试在我的项目中使用名为 SwipeCellKit 的 pod,该 pod 添加了一个名为 SwipeTableViewCell 的类。到目前为止我所做的是:

  • 为 Storyboard创建一个 View Controller 。
  • 创建一个 UIViewController 类。
  • SwipeCellKit 导入到 Swift 文件中。
  • 将 View Controller 分配给类。
  • 将 TableView 添加到 View Controller 。
  • 将委托(delegate)和数据源从 TableView 连接到 View Controller 。
  • 将原型(prototype)单元格添加到 TableView ,并将其命名为“单元格”以作为其可重用标识符。
  • 将单元格类更改为 SwipeTableViewCell。
  • 将 TableView 委托(delegate)添加到 View Controller 。
  • numberOfRowscellForRow 函数添加到我的 UIViewController 类。

这是 cellForRow 的实现:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! SwipeTableViewCell;
    return cell;
}

但是我在 let cell = ... 上出错,说:

Could not cast value of type 'UITableViewCell' to 'SwipeCellKit.SwipeTableViewCell'

为什么?以及如何解决这个问题?我想我已经安排好了一切。我错过了什么吗?

最佳答案

是什么为我解决了这个问题:

Main.Storyboard(或者你有你的观点的地方),确保你想在任何地方使用可重用的“单元格”,在右 Pane 的身份检查器中,你有以下内容:

  • 类设置为SwipeTableViewCell
  • 模块设置为 SwipeCellKit

关于ios - 无法将类型 'UITableViewCell' 的值转换为 'SwipeCellKit.SwipeTableViewCell',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54399985/

相关文章:

c# - 如何在 Monotouch 中获取 iOS 设备和版本

ios - Storyboard - 打开 UIViewController 作为 UIPopoverController

ios - iOS 中的收据验证在沙盒测试期间返回不正确的信息

ios - 如何垂直自动布局 UIView 列表,一个在另一个之上?

ios - 在 UITableView 中显示 Coredata

ios - Objective C Table Cell ContentView view hierarchy is not prepared for the constraint

iphone - 停止 NSTimer 不断增加间隔

ios - 只有单个 uitableview 单元格可以拖动和重新排序

ios - 每周自动更新标签

ios - 在我的应用程序上启用 iCloud 时,现有核心数据数据库未上传到 iCloud