我正在开发一个应用程序。在那个 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 是两个数组。