单击信息按钮时如何在两个 UIViewController 之间进行翻转动画? [英] How to do the flip animation between two UIViewControllers while clicking info button?

查看:22
本文介绍了单击信息按钮时如何在两个 UIViewController 之间进行翻转动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为LoginViewController"的登录页面.我在此页面中有一个信息按钮.如果我点击它,我想显示一些关于我的应用程序的信息.此外,我想使用翻转动画呈现该信息页面.

I have a login page named "LoginViewController". I have an info button in this page. If I click on it, I want to show some information about my application. Also I want to present that information page using flip animation.

创建信息按钮的代码是,

The code for creating info button is,

infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
infoButton.frame = CGRectMake(285, 425, 30, 30);
infoButton.backgroundColor = [UIColor clearColor];

[infoButton addTarget:self 
            action:@selector(displayInfoView) 
            forControlEvents:UIControlEventTouchUpInside];

如果我点击信息按钮,displayInfoView 方法将被调用.在那里我可以显示一个 UIView 来显示一些信息.我说得对吗?

If I click on the info button, the displayInfoView method will be called. There I can show a UIView to display some information. Am I right?

对于翻转动画,我使用了这段代码...

For flip animation, I used this code...

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:.8];

[UIView setAnimationTransition:([loginPageView superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) 
        forView:mainView
        cache:YES]; 

if ([infoView superview]) {
    [infoView removeFromSuperview];
    [mainView addSubview:loginPageView];
}
else {
    [loginPageView removeFromSuperview];
    [mainView addSubview:infoView];
}

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];

这里 loginPageView 是包含信息按钮的登录视图.infoView 是包含有关应用程序信息的视图.mainView 是保存当前视图的公共视图.

Here loginPageView is the login view that contains the info button. infoView is the view that contains the information about application. mainView is the common view that holds the present view.

现在我的问题是,我可以在单击信息按钮时显示另一个视图控制器类而不是显示 UIView 吗?记住翻转动作在 UIView 中工作得很好.但是当我尝试使用 UIViewController 时,这会带来麻烦.

Now my problem is, instead of showing a UIView, can I show an another view controller class while clicking the info button? Remember the flip action works fine with UIView. But when I try with a UIViewController, this makes trouble.

有人可以建议我如何在单击具有翻转效果的信息按钮时显示 UIViewController(在我的应用中,我需要显示 AboutViewController)?

Can someone suggest me how to show an UIViewController ( in my app, I need to show AboutViewController) while clicking the info button with the flip effect?

推荐答案

要翻转到视图控制器:

viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:viewController animated:YES completion:nil];

摆脱它:

[self dismissViewControllerAnimated:YES completion:nil];

这篇关于单击信息按钮时如何在两个 UIViewController 之间进行翻转动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆