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是两个数组。
答案 0 :(得分:0)
您是否尝试过调用[super hitTest:point withEvent:event]?