So I have an UIView
called image, and i am trying to get it to rotate while i am moving the view up and down,here is what I've done so far,but it makes the picture rotate and not go down:
{
return centerY - height / 2 <= 10 ||
centerY + height/ 2 >= self.view.bounds.size.height - 10;
}
-(void)moveUpDownTimerCallback
{
[UIView commitAnimations];
verticalSpeed += acceleration;
degrees+=degreechange;
CGSize sz = image.bounds.size;
image.transform = CGAffineTransformMakeRotation(degrees * M_PI/180),image.layer.anchorPoint =
CGPointMake(rotPointx/sz.width,rotPointy/sz.height);rotPointy = image.center.y;
rotPointx = image.center.x;
CGPoint newCenter = CGPointMake(image.center.x, image.center.y + verticalSpeed);
if ([self hasCollided: image.center.y + verticalSpeed imageHeight:
image.bounds.size.height]) {
acceleration = 0;
[self moveUpDown: 0];
}
else {
image.center = newCenter;
}
}
-(void)moveUpDown:(int) vSpeed
{
verticalSpeed = vSpeed;
if (verticalSpeed != 0 || acceleration != 0) {
if (timer == nil)
timer =[NSTimer scheduledTimerWithTimeInterval:0.05
target:self
selector:@selector(moveUpDownTimerCallback)
userInfo:nil
repeats:YES];
}
}
else {
if (timer != nil) {
[timer invalidate];
timer = nil;
}
}
}
any help would be much appreciated (:
You are taking completely the wrong approach. You should use the new block-based UIView animation methods like animateWithDuration:animations: and it's cousins.
You can animate rotation and movement at the same time.
If you can limit your development to iOS 7 there are new keyframe-based animation methods that let you do a timed sequence of animations quite easily.
try rotating imageview with this method
and moving view with this method