Wednesday, 18 September 2013

Touch events not passing to subviews

Touch events not passing to subviews

i have a scrollview and inside a uiview that contains multiple subviews (
uiimageview). the problem is i can't pass touch gestures to the imageviews
..
-(void)AddImageViewWithFrame:(CGRect)frame andImage:(UIImage*)img
andtag:(int)tag{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(imageTapped:)];
tempimg=[[UIImageView alloc] initWithFrame:frame];
UIImageView *bifat = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"bifat.jpg"]];
tempimg.image=img;
tempimg.tag=tag;
tap.delegate=self;
tempimg.userInteractionEnabled = YES;
view_cuImagini.userInteractionEnabled=YES;
[tempimg addGestureRecognizer:tap];
// [self.view addGestureRecognizer:tap];
[tempimg addSubview:bifat];
[view_cuImagini addSubview:tempimg];
}
-(void)imageTapped:(UITapGestureRecognizer *)rec{
if (rec.state==UIGestureRecognizerStateRecognized) {
NSLog(@"imageTouch with tag %i",rec.view.tag);
}
i want to be able to find the which tempimg was touched does anybody has a
solutions for this?

No comments:

Post a Comment