【问题标题】:How to FlipFromLeft?如何从左翻转?
【发布时间】:2011-09-06 15:27:52
【问题描述】:
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];

我想翻转 containerView,但它不起作用。

【问题讨论】:

    标签: iphone ios ipad animation flip


    【解决方案1】:

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

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

    编辑: 看看another post,似乎添加子视图BEFORE 提交动画是问题所在。你为什么不试试呢?

    希望有帮助!

    【讨论】:

    • 对不起,我不要superview,我只想翻转containerView
    • 没问题!很高兴我能帮上忙!
    【解决方案2】:

    不要使用

    [frontImageView removeFromSuperview];

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

    [UIView setAnimationDidStopSelector:@selector(removeImageView)];
    

    并制作另一种方法,

    -(void) removeImageView
    {
            if([yourImageView superview])
                [yourImageView removeFromSuperview];
    }
    

    【讨论】:

    • [containerView sendSubviewToBack:frontImageView];我只是这样尝试,但没有动画:
    【解决方案3】:

    正确设置containerView的frame。你设置到frontImageView.bounds是不对的。

    【讨论】:

    • 亲爱的 Hitesh,我改变了它,但没有帮助。
    猜你喜欢
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    • 2014-12-31
    • 2012-01-19
    • 2018-01-27
    • 2022-07-10
    • 1970-01-01
    • 2021-04-02
    相关资源
    最近更新 更多