Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit bacba7a6e411b3977af4aac94d6fc042a2ae9986 1 parent 2a6ee05
@diederich diederich authored diederich committed
Showing with 2 additions and 1 deletion.
  1. +2 −1  src/Three20UI/Sources/TTTableViewController.m
View
3  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);
Please sign in to comment.
Something went wrong with that request. Please try again.