开发者

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:UIViewAnimationOptionCur开发者_如何学CveEaseInOut 
        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


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


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];
     }];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜