I have a UIViewController. Within that is a UITableView which is drawn at origin 0,0. I also have a UIScrollView that is drawn at 0,-80 so that it is off screen and not visible.
When a menu button is pressed, I animate the UIViewController's frame down 80px to reveal the UIScrollView.
The problem here is that the UIScrollView does not respond at all.
If I draw the UIScrollView at say 0,0 , where it IS visible on load, it works fine. I can even animate it off screen then back on screen with no issue.
----------
Here is how my view looks
before animating:
Code:
_____________________________
| | Frame -> (0,-80, 320, 80)
| ScrollView | **Offscreen**
|_____________________________|
| | <- Original view (0,0,320,480)
| |
| |
| |
| |
| |
| Original View |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|_____________________________|
----------
When I animate I do the following:
Code:
[UIView animateWithDuration:0.3
delay:0.0
options:(UIViewAnimationOptionAllowUserInteraction |
UIViewAnimationOptionCurveEaseIn)
animations:^{
self.view.frame = CGRectMake(0.0, (self.view.frame.origin.y + container.frame.size.height), self.view.frame.size.width, self.view.frame.size.height);
scroll.userInteractionEnabled = YES;
}
completion:^(BOOL finished) {
if (scrollLoaded == NO) {
[self loadFavorites];
scrollLoaded = YES;
}
}];
----------
Now my view looks like this
after animating:
Code:
_____________________________
| | Frame -> (0, -80, 320, 80)
| ScrollView |
|_____________________________|
| | <- Original view (0, 80, 320, 480)
| |
| |
| |
| |
| |
| Original View |
| |
| |
| |
| |
| |
| |
| |
|_____________________________|
| |
| **Offscreen** |
|_____________________________|
----------
I have subclassed my scrollView to listen more closely for events:
**.h**
Code:
#import <UIKit/UIKit.h>
@interface UIScrollView_ExtraTouch : UIScrollView
@end
**.m**
Code:
#import "UIScrollView+ExtraTouch.h"
@implementation UIScrollView_ExtraTouch
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"scrollview touchesBegan");
[self.nextResponder touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"scrollview touchesMoved");
if(!self.dragging){
[self.nextResponder touchesMoved:touches withEvent:event];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"scrollview touchesEnded");
[self.nextResponder touchesEnded:touches withEvent:event];
}
@end
----------
Nothing goes to the log after the animation. Which I
think means that since the frame is at -80, it believes it to be off screen, thus not receive any type of action.
Is this correct? If so is there a way to fix it?