Take the 2-minute tour ×

Two views need to be resized when a button is clicked in iPad . I Tried it with following code

[UIView animateWithDuration:1.0 animations:^{
    //Target Rect of the View will be given here                         

It works fine with iPad4.2 ,but Crashes with 3.2 version(Incompatible). On Googling found that 3.2 version supports only Animating Views (W/O Blocks) Source: http://developer.apple.com/library/iOS/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/clm/UIView/beginAnimations:context:

They have mentioned its not advisable to use it for 4.0 and later How can I achieve animating the views for both 3.2 and 4.2.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I you really need to support versions below 4.0, you can use this:

[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:1.0]; //In seconds
//Here do your stuff
int newPosY = myImage.frame.origin.y - 10;
[myImage setFrame:CGRectMake(self.frame.origin.x, newPosY, myImage.frame.size.width,     myImage.frame.size.height)];

[UIView commitAnimations];

That moves an UIImageView 10 pixels up.

Also check UIView reference to see all the possibilities.

share|improve this answer
This method is not advisable for 4.0 and above . I am in need of a thing which runs in both the versions –  Shadowtech Sep 22 '11 at 14:05
I'm using it in a bunch of iOS 4.3 projects and also submitted apps to the App Store, what's the problem with it? –  ender Sep 22 '11 at 14:11
Thank You .. It worked Fine –  Shadowtech Sep 23 '11 at 3:50
add comment

Your Answer


