I am using a UITableView
to achieve a scale/unblur effect on my user's profile picture (like in the Spotify App) when I pull down the UITableView
to a negative contentOffset.y
. This all works fine...
Now, when a user pulls down to a contentOffset.y
smaller or equal to a certain value -let's call it maintainOffsetY = 70.0
- and he "lets go" of the view, I would like to maintain this contentOffset
until the user "pushes" the view up again, instead of the view to automatically bounce back to contentOffset = (0,0)
again.
In order to achieve this, I must know when the touches began and ended, which I can do with the following delegate methods:
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView {
// is like touches begin
if ([scrollView isEqual:_tableView]) {
NSLog(@"touches began");
_touchesEnded = NO;
}
}
- (void) scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
// is like touches ended
NSLog(@"touches ended");
if ([scrollView isEqual:_tableView]) {
_touchesEnded = YES;
}
}
Then in
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
I check if the contentOffset.y
is smaller than or equal to maintainOffsetY
and if the user has already "let go" of the table, so it is about to bounce (or already bouncing) back to contentOffset = (0,0)
.
It does not seem to be possible to let it bounce back only to the maintainOffsetY
. Does anybody know a workaround or have an idea on how to solve this?
Any help is much appreciated!