ios8 UITableView scrollToRowAtIndexPath inaccurate

2019-06-21 05:03发布

When I try to scroll all the way to the bottom of a table view when my view first appears, it doesn't scroll to the correct bottom cell. It's somewhere close to the end but not quite.

If the method is called again later, it then scrolls to the bottom. For now my solution was to scroll twice, and it only works if there's a delay on the second one.

I'm wondering if this is a bug in iOS 8 or if there's anything I can actually do the proper way.

NSIndexPath* path = [NSIndexPath indexPathForRow:[self.someArray count] - 1 inSection:0];

[self.someList scrollToRowAtIndexPath:path
                     atScrollPosition:UITableViewScrollPositionBottom
                             animated:NO];

//TODO: this is kindof a dirty hack for now, there seems to be a bug in ios8 auto sizing cells and figuring out the proper scroll location

dispatch_after(0, dispatch_get_main_queue(), ^{
    [self.someList scrollToRowAtIndexPath:path
                     atScrollPosition:UITableViewScrollPositionBottom
                             animated:NO];
});

0条回答
登录 后发表回答