歡迎加入QQ討論群258996829

Swift的聊天框架 Chatto

發(fā)布時(shí)間:2016-01-02 18:22  回復(fù):0  查看:6683  感興趣:112  贊:1   最后回復(fù):2016-01-02 18:22  

Chatto 是一個(gè) Swift 的聊天框架,可以很容易地實(shí)現(xiàn)類似信息 app 那樣的聊天界面,包括圖片發(fā)送,內(nèi)容分頁(yè),可交互的鍵盤等等,是一個(gè)實(shí)現(xiàn)非常完整的解決方案。

Swift的聊天框架 Chatto Swift的聊天框架 Chatto Swift的聊天框架 Chatto Swift的聊天框架 Chatto

示例代碼:

  1. Subclass ChatViewController
  2. Override createChatInputView() to use ChattoAdditions.ChatInputBar or provide your own component
  3. Provide a data source with your messages
  4. Override createPresenterBuilders(). There will be a presenter for each message that will be responsible for the UI of that message.
override func createPresenterBuilders() -> [ChatItemType: [ChatItemPresenterBuilderProtocol]] {
    return [
        TextMessageModel.chatItemType: [
            TextMessagePresenterBuilder(
                viewModelBuilder: TextMessageViewModelDefaultBuilder(),
                interactionHandler: TextMessageHandler(baseHandler: self.baseMessageHandler)
            )
        ]
    ]
}

override func createChatInputView() -> UIView {
    let chatInputView = ChatInputBar.loadNib()
    self.configureChatInputBar(chatInputView)
    self.chatInputPresenter = ChatInputBarPresenter(chatInputView: chatInputView, chatInputItems: self.createChatInputItems())
    return chatInputView
}

override func viewDidLoad() {
    super.viewDidLoad()
    self.chatDataSource = self.myDataSource
}

相關(guān)開源代碼

您還未登錄,請(qǐng)先登錄

熱門帖子

最新帖子

?