动画视图与变化的UITabBarController [英] animating view change with uitabbarcontroller

查看:205
本文介绍了动画视图与变化的UITabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想动画我的看法改变,但我不知道在哪里把我的动画,因为我有一个的UITabBarController控制哪些查看我的什么,我可以切换太..这是正在我appdelegate.m声明文件按在x code ++模板。

I am wanting to animate my view change, however I am not sure where to put my animation since I have a UITabBarController controlling which view I am on and what I can switch too.. This is being declared in my appdelegate.m file as per the xcode template.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}

或它们是这里的一切被装在每一个的ViewController该地区...林想这可能是更好的初始化动画在这里了。

Or their is the area in each viewcontroller where everything gets loaded... Im thinking it might be better to initialize the animation in here.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Super", @"Super");
        self.tabBarItem.image = [UIImage imageNamed:@"SuperIcon"];
    }
    return self;
}

由于我没有一个享有很多做动画的,我woundering在那里我可以宣布code这个peice的时候UITabBarButton感动,希望能动画我的观点改变之前....

As I have not done alot of animation with views before I am woundering where I could declare this peice of code that will hopefully animate my view change when a UITabBarButton is touched....

[UIView transitionWithView:containerView
           duration:0.2
           options:UIViewAnimationOptionTransitionFlipFromLeft
           animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; 
           completion:NULL];

或者我完全错过了船,他们是别的地方我应该这样做呢?

or have I missed the boat completely and is their somewhere else I should be doing this?

推荐答案

请尝试以下code在viewWillAppear中的方法

Try the following code in the viewWillAppear method

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                       forView:self.view cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView commitAnimations];

这工作我的TabBar基于控制器的应用程序。

This worked for me for a tabBar controller based app.

这篇关于动画视图与变化的UITabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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