2013-04-07 61 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