1

タブベースでアプリケーションを開始したので、タブバー全体を無効にしたいのですが、どうすればこれを達成できますか? ここでAppdelegateの私のコード:

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

viewController2タブバー全体を非表示にして、ナビゲーションコントローラーでメインページにしたいだけです。誰でもこれを手伝ってもらえますか?

4

2 に答える 2

1

タブバーの非表示と表示に使用したこの2つの方法を使用してみてください

- (void)hideTabBar {
    UITabBar *tabBar = self.tabBarController.tabBar;
    UIView *parent = tabBar.superview; // UILayoutContainerView
    UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
    UIView *window = parent.superview;

    [UIView animateWithDuration:0.5
                 animations:^{
                     CGRect tabFrame = tabBar.frame;
                     tabFrame.origin.y = CGRectGetMaxY(window.bounds);
                     tabBar.frame = tabFrame;
                     //content.frame = window.bounds;
                 }];
}

- (void)showTabBar {
    UITabBar *tabBar = self.tabBarController.tabBar;
    UIView *parent = tabBar.superview; // UILayoutContainerView
    UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
    UIView *window = parent.superview;

    [UIView animateWithDuration:0.5
                 animations:^{
                     CGRect tabFrame = tabBar.frame;
                     tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame);
                     tabBar.frame = tabFrame;

                     CGRect contentFrame = content.frame;
                     contentFrame.size.height -= tabFrame.size.height;
                 }];
}
于 2012-09-12T04:47:06.787 に答える
0

If you want to preserve the UITabBarController instance and just show one of the views you've added to the UITabBarController full screen, what about displaying the view modally over the UITabBarController?

UINavigationController navController = [[UINavigationController alloc] initWithRootViewController:viewController2];
[self.tabBarController presentModalViewController:navController animated:NO];
于 2012-09-12T04:54:28.457 に答える