i have a scroll view in my application and i want that when the user scrolls it down, so its contentOffset.y reaches -50, the scroll view will animate to the bottom of the screen (at this point the scrollview won’t be visible).
I managed to do this, but when i animate my scrollview back so it gets visible again it loses touch events and won’t scroll anymore.
i already tried to set scrollEnabled and userInteractionEnabled to YES but nothing works. If someone could help i would appreciate.
Thanks.
This is the code when i animate my scroll view to the bottom of the screen
[UIView animateWithDuration:0.5 animations:^
{
CGRect scrollRect = self.scrollView.frame;
CGRect newFrame = CGRectMake(scrollRect.origin.x, 367, scrollRect.size.width, self.scrollView.contentSize.height);
self.scrollView.frame = newFrame;
}
completion:^(BOOL finished)
{
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)] autorelease];
}];
And this is the code where i make my scroll view visible again
[UIView animateWithDuration:0.5 animations:^
{
CGRect scrollRect = self.scrollView.frame;
CGRect newFrame = CGRectMake(scrollRect.origin.x, 0, scrollRect.size.width, self.scrollView.contentSize.height);
self.scrollView.frame = newFrame;
}
completion:^(BOOL finished)
{
self.navigationItem.leftBarButtonItem = nil;
self.scrollView.scrollEnabled = YES;
self.scrollView.userInteractionEnabled = YES;
_canScroll = YES;
}];
and after that i can’t scroll it anymore.
You are setting scroll view height as self.scrollView.contentSize.height so scroll view will not be scrollable vertically.Try by changing it to self.scrollview.frame.height