ios - Swift - 所需方法未实现 : -[JSQMessagesViewController collectionView

标签 ios swift swift3 jsqmessagesviewcontroller

我正在将一个 iOS 应用程序迁移到 Swift 3,但我的 ChatViewController 上一直显示此错误消息。

2017-02-21 16:40:40.599 Jaco[52613:2864859] *** Assertion failure in -[Jaco.ChatViewController collectionView:messageDataForItemAtIndexPath:], /Users/Royal/dev/jab/ios/Pods/JSQMessagesViewController/JSQMessagesViewController/Controllers/JSQMessagesViewController.m:491
2017-02-21 16:40:40.609 Jaco[52613:2864859] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ERROR: required method not implemented: -[JSQMessagesViewController collectionView:messageDataForItemAtIndexPath:]'

这是我的部分代码

  // DATA SOURCE 1
  func collectionView(collectionView: JSQMessagesCollectionView!,
                      messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData! {
    let data = self.messages[indexPath.item]
    return data
  }


  // DATA SOURCE 2
  override func collectionView(_ collectionView: UICollectionView,
                               numberOfItemsInSection section: Int) -> Int {
    return messages.count
  }

我尝试添加“覆盖”,但错误消息仍然存在。

有什么解决办法吗?感谢您的帮助!

最佳答案

改变

func collectionView(collectionView: JSQMessagesCollectionView

func collectionView(_ collectionView: JSQMessagesCollectionView

关于ios - Swift - 所需方法未实现 : -[JSQMessagesViewController collectionView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42372640/

相关文章:

swift - 在 Swift 3 中创建 ValidIndexCollection 协议(protocol)

ios - 后台问题中的 NSMangedObjectContext performBlock

javascript - 当应用程序从后台移动到前台时会触发哪个 JS 事件

ios - 我收到错误 : Value of type 'Bundle' has no member 'pathForResources'

ios - 在 UITableView 中自定义每个单元格的分隔符

ios - 应用程序崩溃并出现错误 : "this class is not key value coding-compliant for the key tableView". 如何修复?

ios - 不能在不可变值数组上使用可变成员是一个只获取属性 swift 3

ios - 跳转到 Xcode 中的定义

iphone - UITextField - 检测内置 iPhone 键盘上的输入?

ios - 如何根据 iPad 上的方向更改布局?