Я пытаюсь создать четыре сенсорных и подвижных надписи на UIView
.
Когда я прикасаюсь к ifAnimaPart01
, они как-то собираются в одном месте, и я не могу коснуться или переместить другие надписи.
Кто-нибудь знает, почему мои четыре метки работают именно так?
Я добавил еще 4 метки, чтобы отобразить координаты x и y для отладки.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if ([touch view] == ifAnimPart01){
ifAnimPart01.center = location;
}
else if ([touch view] == ifAnimPart02){
ifAnimPart02.center= location;
}
else if ([touch view] == ifAnimPart03){
ifAnimPart03.center= location;
}
else if ([touch view] == ifAnimPart04){
ifAnimPart04.center= location;
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[self touchesBegan:touches withEvent:event];
UITouch *myTouch = [touches anyObject];
startPoint1 = [myTouch locationInView:self.view];
xCoordLabel1.text = [NSString stringWithFormat:@"Line OneX = %f", startPoint1.x];
yCoordLabel1.text = [NSString stringWithFormat:@"Line OneY = %f", startPoint1.y];
ifAnimPart01.center = CGPointMake(startPoint1.x, startPoint1.y);
startPoint2 = [myTouch locationInView:self.view];
xCoordLabel2.text = [NSString stringWithFormat:@"Line TwoX = %f", startPoint2.x];
yCoordLabel2.text = [NSString stringWithFormat:@"Line TwoY = %f", startPoint2.y];
ifAnimPart02.center = CGPointMake(startPoint2.x, startPoint2.y);
startPoint3 = [myTouch locationInView:self.view];
xCoordLabel3.text = [NSString stringWithFormat:@"Line ThreeX = %f", startPoint3.x];
yCoordLabel3.text = [NSString stringWithFormat:@"Line ThreeY = %f", startPoint3.y];
ifAnimPart03.center = CGPointMake(startPoint3.x, startPoint3.y);
startPoint4 = [myTouch locationInView:self.view];
xCoordLabel4.text = [NSString stringWithFormat:@"Line FourX = %f", startPoint4.x];
yCoordLabel4.text = [NSString stringWithFormat:@"Line FourY = %f", startPoint4.y];
ifAnimPart04.center = CGPointMake(startPoint4.x, startPoint4.y);
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
}