Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Can I disable animation and clear all messages in current view? #28

Closed
jimmyzzzzzzz opened this issue Aug 26, 2016 · 3 comments
Closed

Comments

@jimmyzzzzzzz
Copy link

Hi, I want to clear message and reload data without animation and without scrolling. is that possible only with just sendText()?

@atainter
Copy link
Contributor

You'll have to call functions on NMessenger instead of NMessengerViewController for this.

To clear all messages without animation, you can use self.messengerView.clearALLMessages() in NMessengerViewController. Reloading messages is harder since it's not the typical "tableView with data source" model. To reload data you'll have to add all of the messages again. There are a few functions in NMessenger which make it easy to add an array of messages, but you'll have to create those messages first. For example:

/**
     Adds an array of messages to the messenger.
     - parameter messages: An array of messages
     - parameter scrollsToMessage: If marked true, the tableview will scroll to the newly added
     - parameter animation: An animation for newly added messages
     - parameter completion: A completion handler
     */
    public func addMessagesWithBlock(messages: [GeneralMessengerCell], scrollsToMessage: Bool, withAnimation animation: UITableViewRowAnimation, completion: (()->Void)?)

would be called with self.messengerView.addMessagesWithBlock(...).

There aren't any public functions in NMessengerViewController which solely create GeneralMessengerCells for text, image, etc. Would it be helpful to expose those functions?

@jimmyzzzzzzz
Copy link
Author

Thanks a lot for the reply. After reading your comment I checked NMessengerViewController.swift source code and found a function called postText() which generates a GeneralMessengerCell. Then I called addMessagesWithBlock() and it's finally working.

@atainter
Copy link
Contributor

Cool. I think I'm still going to make those functions public.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants