Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hey,
 
This question relates to using touch methods in a UIScrollView. I am aware of numerous ways to interact with standard UIViews (touchesBegan, touchesMoved, etc), however, these do not work in a UIScrollView.
 
I have tried several methods to get around this but am getting no joy:
 
Using gestureRecognizers - great, but do not allow for touches to be tracked (like touchesMoved).
 
Using a UISubView - Just can't seem to get this working, I would love some insight here. There's a lot of attempts online, but I can't find a decent tutorial.
 
Here is my current code for the second method:
 
 
 //Set scrollview to size of image
self.myScrollView.contentSize = CGSizeMake(3072, 2304);
 
//Load image in big rect
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 3072, 2304)];
 
//set image to pic in bundle
myImageView.image = [UIImage imageNamed:@"dot.jpg"];
 
//make imageview subview of scrollview
[self.myScrollView addSubview: myImageView];
 
//Making subview for touches
CGRect frame  = CGRectMake(0, 0, 3072, 2304);
touchView = [[UIScrollView alloc] initWithFrame:frame];
[self.myScrollView addSubview: touchView];
 
//Allow for 2 touches to move screen
for (UIGestureRecognizer *gestureRecognizer in myScrollView.gestureRecognizers)
{
    if ([gestureRecognizer  isKindOfClass:[UIPanGestureRecognizer class]])
    {
        UIPanGestureRecognizer *panGR = (UIPanGestureRecognizer *) gestureRecognizer;
        panGR.minimumNumberOfTouches = 2;            
    }
} 
 

Any insight or help would be great!
Posted 20-May-13 6:40am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 280
1 Sergey Alexandrovich Kryukov 279
2 CPallini 205
3 Maciej Los 197
4 Afzaal Ahmad Zeeshan 160
0 OriginalGriff 5,635
1 DamithSL 4,496
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 20 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100