Skip to content

Commit

Permalink
[Three20UI] fixed restoring to a wrong scrollview offset
Browse files Browse the repository at this point in the history
when restoring the tableView offset, the maximum offset
can be a number < 0, if the contentSize doesn't fill the
whole tableview. If that's the case, set the maximum scrollOffset
to 0.
  • Loading branch information
diederich committed Jan 11, 2012
1 parent 2a6ee05 commit bacba7a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Three20UI/Sources/TTTableViewController.m
Expand Up @@ -327,7 +327,8 @@ - (BOOL)persistView:(NSMutableDictionary*)state {
- (void)restoreView:(NSDictionary*)state {
CGFloat scrollY = [[state objectForKey:@"scrollOffsetY"] floatValue];
if (scrollY) {
CGFloat maxY = _tableView.contentSize.height - _tableView.height;
//set to 0 if contentSize is smaller than the tableView.height
CGFloat maxY = MAX(0, _tableView.contentSize.height - _tableView.height);
if (scrollY <= maxY) {
_tableView.contentOffset = CGPointMake(0, scrollY);

Expand Down

0 comments on commit bacba7a

Please sign in to comment.