1

I have a chat application that uses Parse as a back-end. Let's say there's a conversation that looks something like this in the table so far:

I said: Hello

He said: Hey there

Now, if I want to type something in and click send, the table would go blank for a bit and then show all three messages. How can I achieve this affect in a much smoother way? For example, when I hit send, the message just pops under all the other messages without it going blank because it is refreshing the data and adding the new message.

When the send button is pressed, among other code, these two pieces of code run:

    self.messagesArray.append(messageObject)
    self.loadObjects()

The table is handled by a class that extends PFQueryTableViewController. Anyone have any ideas?

Navio53
  • 591
  • 1
  • 6
  • 20
  • https://github.com/jessesquires/JSQMessagesViewController check out this one – Neil Galiaskarov May 31 '15 at 06:21
  • what happens inside self.loadObjects() call? are you reloading the table view? – Clement Prem May 31 '15 at 06:49
  • @Clement It clears the table and reloads the data. I also have a direct reference to the UITableView but when I call its reload data method, the table goes blank causing me to have to go back to the previous controller and come back again to the chat controller in order for the messages to show. – Navio53 May 31 '15 at 07:23

1 Answers1

0

Trivially you can change to using loadObjects:clear: instead of loadObjects so you can specify that the table isn't cleared.

Alternatively, and more efficiently for the addition of the users own messages, you can add the item to the objects array (a mutable copy of) and then set that new array as objects.

If these options don't obtain the full effect you're after then you need to stop using PFQueryTableViewController so you have full control over how the table view is managed.

Wain
  • 118,658
  • 15
  • 128
  • 151