AlexBarinov/UIBubbleTableView

scrolling to bottom

Opened this issue · 3 comments

Why there is no scrolling to bottom support, I've added the following line to the end of the reloadData
[self setContentOffset:CGPointMake(CGFLOAT_MAX, CGFLOAT_MAX)];
and its working fine for me.

Similar Issue, i solved by creating a category with a little helper function.

#import "UIBubbleTableView+ScrollHelper.h"

@implementation UIBubbleTableView (ScrollHelper)


-(void) scrollToBottom
{
    CGPoint bottomOffset = CGPointMake(0, self.contentSize.height - self.bounds.size.height);
    [self setContentOffset:bottomOffset animated:YES];
}


@end

hi, i have written this piece of code for scroll to bottom which works fine for me.

-(void) scrollToBottom
{
int lastSection=[bubbleTable numberOfSections]-1;
int lastRowNumber = [bubbleTable numberOfRowsInSection:lastSection]-1;
NSIndexPath* ip = [NSIndexPath indexPathForRow:lastRowNumber inSection:lastSection];
[bubbleTable scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

Another snippet: I have a previously sorted list of messages, and needed to be able to scroll to a particular message: e.g. scroll to the first unread message:

int rows, section = 0, sections = [bubbleTable numberOfSections];
for ( ; section < sections; section++) {
    rows = [bubbleTable numberOfRowsInSection:section];
    if (searchIndex < rows) {
        NSIndexPath * path = [NSIndexPath indexPathForRow:searchIndex inSection:section];
        [bubbleTable scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
    } else {
        searchIndex -= rows;
    }
}

Unfortunately, because UIBubbleTableView:reloadData creates an internal list of cells and sorts them by date, this technique is not always going to be applicable.