使用动画切换视图 UIViewAnimationTransitionCurlUp

发布于 2024-11-10 15:25:30 字数 908 浏览 0 评论 0原文

我正在开发一个 iPad 应用程序,它在背景主视图前面有一个小的弹出视图。

弹出视图显示一张照片及其相关注释等。主视图是一堆缩略图,

我想实现一些操作,例如向左/向右滑动,以用带有动画的新弹出视图替换弹出视图。

// 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];

嗯,这行不通。我无法删除动画块中的旧视图,否则动画将不会触发。我也无法在完成块中删除它,因为在动画过程中,旧图像在其下方仍然可见。

我花了相当多的时间来处理这些序列,但就是无法让它发挥作用。请帮忙。

提前致谢。 狮子座

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画▽骨i 2024-11-17 15:25:30

我最终通过设置隐藏在动画块中的旧视图来解决这个问题。动画将在动画过程中显示新视图。

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

︶葆Ⅱㄣ 2024-11-17 15:25:30

我是这样做的:它在风景中效果很好,从下到上卷曲

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

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];
     }];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文