0

我正在开发一个应用程序。在那个 iam 中使用一个 uiimageview。并获取另一个图像视图并添加到第一个 imageview。并将 uitapgesturerecognizer 操作添加到第二个 imageview。如果第二个 imageview 可以出现在第一个 imageview 之外,如果我们点击它imageview 那么没有检测到手势动作。所以请告诉我如何解决这个问题。我的代码如下所示。

  UIImageView *img1=[[UIImageView alloc]initWithFrame:CGRectMake(100,100,500 ,500)];
 [self.view addsubview:img1];

float x=[[xvalues objectAtIndex:h] floatValue];
            float y=[[yvalues objectAtIndex:h] floatValue];
            UIImage *pinimage=[UIImage imageNamed:@"PINpurple.png"];
UIImageView *img3=[[UIImageView alloc]initWithFrame:CGRectMake(x-pinimage.size.width,y-pinimage.size.height,pinimage.size.width ,pinimage.size.height)];
            img1.userInteractionEnabled=YES;
            img3.userInteractionEnabled=YES;
 UITapGestureRecognizer *tap5=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(calculate:)];
            tap5.delegate=self;
            [img3 addGestureRecognizer:tap5];
            [img1 addSubview:img3];

这里 xvalues 和 yvalues 是两个数组。

4

1 回答 1

0

您是否尝试在该点调用 [super hitTest:point withEvent:event] ?

于 2012-06-18T07:50:56.940 回答