3
UIImageView * frontImageView = [[UIImageView alloc] initWithImage:[UIImage 
                                                                   imageNamed:@"view.png"]];

UIView * containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = self.view.center;

[self.view addSubview:containerView];
[containerView addSubview:frontImageView];

UIImageView * backImageView = [[UIImageView alloc] initWithImage:[UIImage 
                                                                  imageNamed:@"view.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                       forView:containerView 
                         cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];

我想翻转容器视图,但它不起作用。

4

3 回答 3

2

是关于同一问题的类似帖子。@Jason Harwig 建议您尝试:

尝试self.view.superview在动画过渡视图中使用 showMoreInfo:

编辑:查看另一篇文章,似乎提交动画之前添加子视图是问题所在。你为什么不试试呢?

希望有帮助!

于 2011-09-06T06:54:35.403 回答
0

不要使用

[frontImageView removeFromSuperview];

在这个函数中。发生的事情是在动画发生之前,您的视图会从超级视图中删除。因此,没有动画。而是使用这个。

[UIView setAnimationDidStopSelector:@selector(removeImageView)];

并制作另一种方法,

-(void) removeImageView
{
        if([yourImageView superview])
            [yourImageView removeFromSuperview];
}
于 2011-09-06T06:54:40.470 回答
0

正确设置containerView的frame。你把它设置为frontImageView.bounds是不对的。

于 2011-09-06T07:06:20.527 回答