leo
leo

Reputation: 1011

switch view with animation UIViewAnimationTransitionCurlUp

I am working on an iPad app which has a small popup view in front of the background main view.

The popup view displays one photo and its related notes etc. The main view is a bunch of thumbnails

I want to implement actions, like swipe left/right, to replace the popup view with a new popup view, with animation.

// popView is the existing pop up view to be replaced
MyPopupViewController *newPopView = [[MyPopupViewController alloc] initWithData:...];
[UIView animateWithDuration:0.4 
        delay:0 
        options:UIViewAnimationOptionCurveEaseInOut 
        animations: ^{
                   [self.view addSubView: newPopView.view];
                   [popView removeFromSuperView];
                   [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp 
                                          forView:popView cache:YES]; 
        } completion:^(BOOL finished) { popView = newPopView } 
];
[newPopView release];

Well, this doesn't work. I can't remove the old view in animation block otherwise the animation won't fire. I can't remove it in the completion block either, because during the animation, the old image will still be visible under itself.

I've spent quite some time playing with the sequences but just can't get it to work. Please help.

Thanks in advance. Leo

Upvotes: 3

Views: 1217

Answers (2)

Hashem Aboonajmi
Hashem Aboonajmi

Reputation: 13830

Here is how I did: it works well in landscape an curls from bottom to top

[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionTransitionCurlUp animations:^()
     {
         [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp
                                forView:self.welcomScreen cache:YES];
         [self.welcomScreen setHidden:YES];
     }completion:^(BOOL finished)
     {
         [self.welcomScreen removeFromSuperview];
     }];

Upvotes: 0

leo
leo

Reputation: 1011

I finally fixed this by setting the old view hidden in animation block. The animation will reveal the new view during animation.

Upvotes: 1

Related Questions