欢迎加入QQ讨论群258996829

Swift的聊天框架 Chatto

发布时间:2016-01-02 18:22  回复:0  查看:4084  感兴趣:97  赞:1   最后回复:2016-01-02 18:22  

Chatto 是一个 Swift 的聊天框架,可以很容易地实现类似信息 app 那样的聊天界面,包括图片发送,内容分页,可交互的键盘等等,是一个实现非常完整的解决方案。

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
}

相关开源代码

您还未登录,请先登录

热门帖子

最新帖子