1

我有一个滚动视图和一个包含多个子视图(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 有人对此有解决方案吗?

4

0 回答 0