Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try subclassing a UIImageView and handle the touches code in that subclass. If you need to pass the touch to the parent for some reason, you can handle the touch then send it on to the parent which would be your view controller.</p> <p>EDIT: </p> <p>have your custom class like this</p> <pre><code>@interface CustomImageView : UIImageView {}@end @implementation CustomImageView -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"touch began %d",self.tag); [self.nextResponder touchesBegan:touches withEvent:event]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"touch moved %d",self.tag); [self.nextResponder touchesMoved:touches withEvent:event]; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"touch ended %d",self.tag); [self.nextResponder touchesEnded:touches withEvent:event]; } @end </code></pre> <p>and have your parrent code something like this</p> <pre><code>@implementation trashmeTouchIpadViewController -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"parent Touch Began"); //do parent stuff } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"parent Touch ended"); //do parent stuff } - (void)viewDidLoad { [super viewDidLoad]; [self.view setMultipleTouchEnabled:YES]; UIImage *i1 = [UIImage imageNamed:@"img1.jpg"]; CustomImageView *v1 = [[CustomImageView alloc] initWithImage:i1]; v1.frame = CGRectMake(100, 100, 200, 200); v1.userInteractionEnabled = YES; v1.multipleTouchEnabled = YES; v1.tag = 111; [self.view addSubview:v1]; [v1 release]; UIImage *i2 = [UIImage imageNamed:@"img2.jpg"]; CustomImageView *v2 = [[CustomImageView alloc] initWithImage:i2]; v2.frame = CGRectMake(500, 100, 200, 200); v2.userInteractionEnabled = YES; v2.multipleTouchEnabled = YES; v2.tag = 999; [self.view addSubview:v2]; [v2 release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload