委托和数据源在 MessageKit 中不工作 Swift IOS

Delegate and DataSource not woking in MessageKit Swift IOS

我正在使用 MessageKit 聊天,当我调用它的委托和数据源时它说(在范围内找不到 'messagesCollectionView')请查看代码并指导我,谢谢。

import UIKit
import FirebaseAuth
import MessageKit

struct Message: MessageType{
    var sender: SenderType
    var messageId: String
    var sentDate: Date
    var kind: MessageKind
}

struct sender: SenderType{
    var photo: String
    var senderId: String
    var displayName: String
}
class ChatDashboard: UIViewController {

    @IBOutlet weak var lblUser: UILabel!
    
    var userActive: String? = nil
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

         messagesCollectionView.messagesDataSource = self
         messagesCollectionView.messagesLayoutDelegate = self
         messagesCollectionView.messagesDisplayDelegate = self //not working delegate and datasource
        if let userData = userActive{
            self.lblUser.text = userData
        }
        
    }
    
    override func viewDidAppear(_ animated: Bool) {
    }

}

看看他们的示例项目用法。 应该消除很多困惑。

Link: https://github.com/MessageKit/MessageKit/tree/master/Example

关于您的查询,

找不到 messagesCollectionView,因为 MessagesViewController需要扩展才能访问它。