Permalink
Browse files

[Three20UI] fixed restoring to a wrong scrollview offset

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 Nov 22, 2010
1 parent 2a6ee05 commit bacba7a6e411b3977af4aac94d6fc042a2ae9986
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/Three20UI/Sources/TTTableViewController.m
@@ -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);

0 comments on commit bacba7a

Please sign in to comment.