From bacba7a6e411b3977af4aac94d6fc042a2ae9986 Mon Sep 17 00:00:00 2001 From: Stephan Diederich Date: Mon, 22 Nov 2010 15:48:36 +0100 Subject: [PATCH] [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. --- src/Three20UI/Sources/TTTableViewController.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Three20UI/Sources/TTTableViewController.m b/src/Three20UI/Sources/TTTableViewController.m index 9409d68e2e..078118997e 100644 --- a/src/Three20UI/Sources/TTTableViewController.m +++ b/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);