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?
Trivially you can change to using
loadObjects:clear:
instead ofloadObjects
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 asobjects
.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.