使用动画切换视图 UIViewAnimationTransitionCurlUp
我正在开发一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终通过设置隐藏在动画块中的旧视图来解决这个问题。动画将在动画过程中显示新视图。
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