2011-12-16 60 views
0

因此,我有一個UITabbarController,其中UINavigationController。在按下按鈕時,我想引入另一個UINavigationController,如使用presentModalViewController:animated:時的動畫效果,但我不希望它隱藏TabBar。如何使用自底向上動畫呈現UIViewController而不隱藏TabBar

UIKit(3.1.3及更高版本)有什麼我可以使用的或我將不得不做動畫自己?

回答

4

只是測試代碼,也許你需要設置navigationControllerproperty,如果你需要做某事像pushViewController:animated:

UIViewController * aViewController = [[UIViewController alloc] init]; 
[aViewController.view setFrame:self.view.frame]; 
[aViewController.view setBackgroundColor:[UIColor redColor]]; 

UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:aViewController]; 
[aViewController release]; 
[navigationController.view setFrame:CGRectMake(0.0f, 480.0f, 320.0f, 480.0f)]; 
[self.navigationController.view addSubview:navigationController.view]; 

[UIView animateWithDuration:0.3f 
         delay:0.0f 
        options:UIViewAnimationOptionCurveLinear 
       animations:^{ 
        [navigationController.view setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)]; 
       } 
       completion:nil]; 
[navigationController release]; 
1

默認情況下,從下往上呈現一些東西的唯一方法是presentModalViewController。實際上,您可以覆蓋navigationController的動畫,但這不是通過調用其他方法就可以實現的,您必須創建自己的動畫並處理動畫。

另一種可能欺騙這個的方法是重新加載你的tabBar在你模態展示的視圖中,但這可能會變得混亂。

+0

HM:/我想通過導航控制器做到這一點,但現在看來似乎是不可能的一個navigatiocontroller推到另一個 – Ahti 2011-12-16 16:44:14