Swift 2016-01-02 18:22
Swift的聊天框架 Chatto
回复:0 查看:6813 感兴趣:112 赞:1
Chatto 是一个 Swift 的聊天框架,可以很容易地实现类似信息 app 那样的聊天界面,包括图片发送,内容分页,可交互的键盘等等,是一个实现非常完整的解决方案。
示例代码:
- Subclass ChatViewController
- Override createChatInputView() to use ChattoAdditions.ChatInputBar or provide your own component
- Provide a data source with your messages
- 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 }