我试图在 touchesbegan 方法中有多个对象(2 UIImageViews)
我正在使用以下代码,但无法正常工作。没有错误,但位置只是搞砸了。我应该怎么做?
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [[event allTouches] anyObject];
if (image1.image == [UIImage imageNamed:@"ball.png"]){
CGPoint location = [touch locationInView:touch.view];
image1.center = location;
}
if (image1.image == [UIImage imageNamed:@"ball2.png"]){
CGPoint location = [touch locationInView:touch.view];
image2.center = location;
}
}