So for the past 2 days i have been searching for an answer to this question and I can't seem to find one.
The effect I'm trying to reproduce is better explained with a real example: on the ipod app (on any iphone) in the now playing view, when you touch the top right button it flips between album art with some controls and album list with rating. Notice that the button itself flips too and at the same time as the container view below. I can't get this to work:
[UIView transitionWithView:self.container1
duration:1
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
if ([flipView superview])
{
[self.flipView removeFromSuperview];
[self.container1 addSubview:coverView];
}
else
{
[self.coverView removeFromSuperview];
[self.container1 addSubview:flipView];
}
}
completion:NULL];
[UIView transitionWithView:self.container2
duration:1
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
if ([flipped superview])
{
[self.flipped removeFromSuperview];
[self.container2 addSubview:original];
}
else
{
[self.original removeFromSuperview];
[self.container2 addSubview:flipped];
}
}
completion:NULL];
I'm having 2 problems with this code:
- Although this may be fairly easy, since I'm a noob I don't know how can I flip it to Left in the first animation and to Right in the second. Like this, it always flips to the Left side;
- "original" and "flipped" are both instances of an UIButton class. The app crashes when I press the button (I'm guessing because they're UIButton's since with the UIImageView's it works fine). Why is this a problem being that UIButton inherits from UIView and all?
Anyone has any ideas that might point me in the right direction? (Sorry for the long post, and thanks for any input!)