Question

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 // :)

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top