AlexBarinov / UIBubbleTableView

Cocoa UI component for chat bubbles with avatars and images support
http://alexbarinov.github.com/UIBubbleTableView/
842 stars 232 forks source link

Autoscroll added, automatically moves to bottom of chat UIBubbleTableView when reloadData is called. #45

Open soroushjp opened 11 years ago

soroushjp commented 11 years ago

For me, I wanted my chat to scroll to bottom on arrival of a new message. Conveniently, this is when reloadData is called, so until a developer options list is made available, this seems like a great solution for most use cases.

If this would be better served as an optional parameter, I can code it up, just let me know.

EDIT: I refactored this code out as a scrollToBottom instance method. This could make sense as a function left accessible for the user so they can call it as needed, instead of building an autoscroll option or forcing it on people using the library. Just an idea. For now, left in reloadData method to act as autoscroll.

EDIT2: For my own application, I needed a place without animation during scrolling, so I extended this method to scrollToBottomWithAnimation:(BOOL)animated. I then put this in the header as an accessible method for the rest of my controllers. If this seems useful, let me know, I will submit a separate pull request.

EDIT3: I added the optional animation code and added method prototype to header. Let me know if this is not the route you want to take with the project.

MindTheGap commented 11 years ago

Thanks a lot for this.

I've been wondering how to implement auto scroll without learning all the BubbleTableView implementation!

soroushjp commented 11 years ago

No worries, glad it helped. I'm working a lot with this library in my project and have been through the implementation so let me know if you run into any other issues.

v0idbring3r commented 11 years ago

Hey, I am having a problem. It doesn't let me scroll to bottom anytime. As soon as i scroll to the bottom and release it, it automatically scrolls back to the middle.

If you have a solution or perhaps a reason for this occurrence, please help me. Thanks in advance

anuradhavasudeva commented 9 years ago

@soroushjp solution does not work because there is still an issue with the function animateTextField. img_1258