views:

1119

answers:

1

Hi,

Parent is a UIImageView, child is a UIImageView. Both have enable user interaction set to yes. Problem is that child will cover parent view, so can't fire touches from the parent, need to do them from the child. But how can the child either set a new image file in the parent based on it's touch events which can be acquired by user touch, or how can the parent get those events by object (or not) and the x and y coordinates relative to the window when it does? Anything helps!

Thanks // :)

+1  A: 

I'll cover the "child touch event set image file of parent" (the touches will be for the whole screen)

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
NSUInteger tapCount = [touch tapCount];

switch (tapCount) {
 case 1:
  [self performSelector:@selector(parent) withObject:nil afterDelay:0];

  break;
 case 2:

  break;
 default:
  break;
}

- (void)parent
{


UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"parent" ofType:@"png"]];
[parent setImage:img];
}

}

as long as the UIImageViews are in the same view you should be fine and dandy like sour candy

OR if you just want it if you touch the child image view, add a UIButton, drag it over the child, and set it as a custom button (will make it invisible) then set the -(void)parent to -(IBAction)parent and add it to the .h

Matt S.
Awesome! One glitch... had to set the final "parent" to "super". Then it worked great! Thanks // :)
Spanky
yea, that touchesBegan thing is awesome, for example, if you want to double tap, just add it on case 2, triple, case 3 (doesn't exist in this example) case 4, 4 taps. It's great!
Matt S.