Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #72 from cHoco/master

More consistent TUTableView scrolling behavior with maintainContentOffsetAfterReload
  • Loading branch information...
commit ae84520199a41904dc4e26661cd0c88feb463d77 2 parents 4f0d1e8 + 90b1d69
@joshaber joshaber authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/UIKit/TUITableView.m
View
12 lib/UIKit/TUITableView.m
@@ -658,10 +658,16 @@ - (BOOL)_preLayoutCells
CGFloat previousOffset = 0.0f;
NSIndexPath *savedIndexPath = nil;
CGFloat relativeOffset = 0.0;
+
+ CGFloat resizingOffset = 0.0;
+ if ([self.nsView inLiveResize]) {
+ resizingOffset = (_lastSize.height - bounds.size.height);
+ }
+
if(_tableFlags.maintainContentOffsetAfterReload) {
previousOffset = self.contentSize.height + self.contentOffset.y;
} else {
- if(_tableFlags.forceSaveScrollPosition || [self.nsView inLiveResize]) {
+ if(_tableFlags.forceSaveScrollPosition || resizingOffset) {
_tableFlags.forceSaveScrollPosition = 0;
NSArray *a = [INDEX_PATHS_FOR_VISIBLE_ROWS sortedArrayUsingSelector:@selector(compare:)];
if([a count]) {
@@ -669,7 +675,7 @@ - (BOOL)_preLayoutCells
CGRect v = [self visibleRect];
CGRect r = [self rectForRowAtIndexPath:savedIndexPath];
relativeOffset = ((v.origin.y + v.size.height) - (r.origin.y + r.size.height));
- relativeOffset += (_lastSize.height - bounds.size.height);
+ relativeOffset += resizingOffset;
}
} else if(_keepVisibleIndexPathForReload) {
savedIndexPath = _keepVisibleIndexPathForReload;
@@ -690,7 +696,7 @@ - (BOOL)_preLayoutCells
// restore scroll position
if(_tableFlags.maintainContentOffsetAfterReload) {
- CGFloat newOffset = previousOffset - self.contentSize.height;
+ CGFloat newOffset = previousOffset - self.contentSize.height - resizingOffset;
self.contentOffset = CGPointMake(self.contentOffset.x, newOffset);
} else {
if(savedIndexPath) {
Please sign in to comment.
Something went wrong with that request. Please try again.