我正在尝试对我拥有的不同图像应用拖放功能但我的代码不起作用,它对我视图中的图像没有影响。
这是我的代码:
if([touch view]==imageOne){
CGPoint location=[touch locationInView:self.view];
imageOne.center=location;
return;
}
if([touch view]==imageTwo){
CGPoint location=[touch locationInView:self.view];
imageTwo.center=location;
return;
}
if([touch view]==imageThree){
CGPoint location=[touch locationInView:self.view];
imeageThree.center=location;
return;
}
if([touch view]==imageFour){
CGPoint location=[touch locationInView:self.view];
imageFour.center=location;
return;
}
if([touch view]==imageFive){
CGPoint location=[touch locationInView:self.view];
imageFive.center=location;
return;
}
答案 0 :(得分:2)
将UIImageView的userInteractionEnabled
属性设置为YES
。默认情况下,它将是NO
。有关详细信息,请参阅Apple documentation