i'm new to Objective-C and Xcode... I'm following a tutorial that explain how to move a car(a ImageView) to the top of the screen, rotate it, an then back to the bottom of the display.
This is the code:
- (IBAction)testDrive:(id)sender {
CGPoint center = CGPointMake(_car.center.x, self.view.bounds.origin.y + _car.bounds.size.height/2 +100);
[UIView animateWithDuration:3
animations:^ { _car.center = center;}
completion:^(BOOL finished){[self rotate];}];
}
- (void) rotate{
CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI);
void (^animation)() = ^() { _car.transform = transform;
};
void (^completion)(BOOL) = ^(BOOL finished){
[self returnCar];
};
[UIView animateWithDuration:3 animations:animation completion:completion];
}
The problem is that the car moves to the top, but then it's position is resetted at the bottom of the screen, like the center was resetted to the default center value, and only then is rotated.. I can't find a solution, need your help!