Mani
Mani

Reputation: 1841

Expand and collapse animation not working in ios6

I am working on UIView. This view is expand and collapse on button click. Its working on iOS<=5 but not working iOS6. Can you please correct my code or explain it.

Thanks.

My Code:

    CGFloat x= 60,y = 391,w1=210,h1=48;
    [ViewShare setHidden:YES];
    [UIView beginAnimations:@"animationOff" context:NULL]; 
    [UIView setAnimationDuration:0.2f];
    [ViewShare setFrame:CGRectMake(x, y, w1, h1)];
    [UIView commitAnimations];

And Ref Page

Thanks..

Upvotes: 0

Views: 791

Answers (1)

Mr Bonjour
Mr Bonjour

Reputation: 3400

Mani, you should use the block based animation instead, because the use of commit animation is discouraged after iOS 4.0.

There is lot of GUI bug code if you try to cross lot of IOS, and try to use "deprecated" method. By the way your code is correct.

If you don't use IOS before 4.0, use instead

animateWithDuration:animations:completion:

Here's an example:

[UIView animateWithDuration: 0.2f
     animations:^{
    [ViewShare setFrame:CGRectMake(60, 391, 210, 48)];
}
     completion:^(BOOL finished){ 
    // what you want when the animation is done
}];

Note that sometime, you need to switch behavior depending on iOS version, it is very always GUI related. That make me very nervous. :)

Upvotes: 1

Related Questions