1

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!)

cjarp
  • 11
  • 3
  • Is there any output logged when the app crashes? – Rob Lourens Jan 04 '11 at 04:03
  • It says the following: 2011-01-09 04:30:49.752 flipamos[18686:207] -[NSCFString superview]: unrecognized selector sent to instance 0x4b31670 2011-01-09 04:30:49.756 flipamos[18686:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString superview]: unrecognized selector sent to instance 0x4b31670' This means the button is not recognizing the superview in "removeFromSuperview" call? still lost :( – cjarp Jan 09 '11 at 04:31

1 Answers1

0

i think you are trying to do something similar to this thread: How to do a flip animation between more than two UIViews? ?

Community
  • 1
  • 1
Moszi
  • 3,236
  • 2
  • 22
  • 20
  • Maybe I just didn't get the hang of this properly but my problem is more with the button itself flipping than with the views... – cjarp Jan 04 '11 at 03:41