2013-04-07 62 views
0

我试图模仿TweetBot/NetBot动画tabBar后,从帐户tableView的操作推动。当视图被完全推入时,taBar才会从底部开始生成动画。我试过各种各样的隐藏/放映方法,并且在“演出”部分看起来都失败了。如何在视图完全推入视图后使tabBar生成动画?

有没有人有这样的建议?

回答

0

首先,我认为你不使用UITabViewController,因为它不能被推入到UINavigationController栈中,所以我认为你使用的是嵌入UIViewController的独立UITabBar。这个假设是正确的吗?

尝试使用此代码(我没有尝试过)。

- (void)viewDidAppear { 
    [super viewDidAppear]; 

    // Calls showTabBar method after SOME_DELAY. You can also call directly [self showTabBar] if you want zero delay. 
    [self performSelector:@selector(showTabBar) afterDelay:SOME_DELAY]; 
} 

- (void)showTabBar { 
    // Before the animation begins, your UITabBar must be outside the view controller's view frame. 
    CGRect tabBarFrame = CGRectMake(0, 
            CGRectGetHeight(self.view.bounds), 
            CGRectGetWidth(self.view.bounds), 
            CGRectGetHeight(self.tabBar.frame); 
    self.tabBar.frame = tabBarFrame; 

    // Let's start with the animation, setting a new frame for tab bar inside an animation block 
    [UIView animateWithDuration:ANIMATION_DURATION animations:^{ 
     // Change origin Y. It assumes that the height of self.tabBar is right, otherwise put the height you want instead of CGRectGetHeight(self.tabBar.frame). 
     tabBarFrame.origin.y = CGRectGetHeight(self.view.bounds) - CGRectGetHeight(self.tabBar.frame); 

     self.tabBar.frame = tabBarFrame; 
    }]; 
} 
+0

好的,我* *是*在使用NavController - > TabBarController之前,你的答案。既然Storyboard让我这样做,而且一切正常,我认为它是好的。你是说我需要使用普通的VC,并且只是推出我自己的Tabbarcontroller?我可以将tabbar制作成视觉效果非常好,但是如果能够工作的话,那么在后面展示它会非常有用。 – Mike 2013-04-07 21:53:41

+0

[文档](http://bit.ly/hUDRwc)约UINavigationController的规定: 'pushViewController:动画:'_ “该对象不能被标签栏控制器的一个实例,” _ 'initWithRootViewController:'_”这个对象不能是UITabBarController类的一个实例。“_ 无论如何,也许推动它可以工作,但我不知道这是否会导致一些不当行为。 你确定你确实需要将它推入导航堆栈吗?也许你可以在需要的时候隐藏tabbar来达到同样的结果。 你试过我的动画代码,顺便说一句? – 2013-04-07 23:12:33

+0

决定去一个不同的方向,直到我能想出来。感谢您试图帮助亚历山德罗:) – Mike 2013-04-10 10:24:20