触摸未传递到子视图的事件

时间:2013-09-18 09:25:45

标签: iphone ios objective-c uigesturerecognizer subview

我有一个滚动视图,在一个包含多个子视图(uiimageview)的uiview中。问题是我无法将触摸手势传递给图像视图。

@interface photoLibrary (){
    UIView *view_cuImagini;
}
    @property (nonatomic,retain) UIScrollView *scrl_images;
@end

@implementation photoLibrary
@synthesize scrl_images;    
//..
- (void)viewDidLoad{
    [super viewDidLoad];
//...
scrl_images.minimumZoomScale=0.4;
    view_cuImagini=[[UIView alloc]initWithFrame:CGRectMake(scrl_images.frame.origin.x, scrl_images.frame.origin.y, scrl_images.frame.size.width, scrl_images.frame.size.height)];
    view_cuImagini.backgroundColor=[UIColor blackColor];
    [scrl_images addSubview:view_cuImagini];
}

 -(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);
}

我希望能够找到触及的tempimg 有没有人有解决方案?

0 个答案:

没有答案