I\'m working on an iPhone game whose code I inherited from another developer. The gaming grid is a UIScrollView having a contentSize of 1000x1000. The grid co
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
this might do the trick.... any touchesMoved can trigger a method that would scroll with a velocity propotional to the distance between the center of the screen(or anywhere else) and last recorded position of touch until a touchesEnded.
I had exactly the same problem (and wasted a lot of time).
Then I tried to set the cancelsTouchesInView
property as soon as possible (I did it in viewDidLoad
)... and it worked for me (as shown here)!
- (void)viewDidLoad {
[super viewDidLoad];
/* other initializations */
scrollView.panGestureRecognizer.cancelsTouchesInView = NO;
}
This works in iOS 5. Before iOS 5 you need to go through all the recognizers, find the panGestureRecognizer, and then set the property. So this should be a universal solution:
- (void)viewDidLoad {
[super viewDidLoad];
/* other initializations */
for (UIGestureRecognizer *gesture in scrollView.gestureRecognizers){
if ([gesture isKindOfClass:[UIPanGestureRecognizer class]]){
gesture.cancelsTouchesInView = NO;
}
}