1

UITabBarControllerからUITabBarを非表示/削除しようとしています。iPhoneバージョンにはUITabBarがありますが、ナビゲーションをiPadバージョンの新しいViewControllerに移動しました。新しいメニューは、UITabBarDelegateメソッドを使用して機能し、UIViewControllerを切り替えます。

ここまでは順調ですね。

今必要なのは、UITabBarを非表示にすることだけです。

カスタムUITabBarControllerがあり、self.tabBar.hidden=YES;を使用してみました。しかし、画面いっぱいに表示する必要があります。

ありがとうございました

4

2 に答える 2

3

したがって、いくつかのオプションがあります。タブビューがナビゲーションコントローラーであるとします。その場合、使用したい「実際の」viewControllerをすぐにプッシュする一時的なviewControllerを作成でき、「実際の」viewControllerには以下のメソッドが実装されています。後で、navigationControllers viewControllers配列をリセットすることにより、一時的なコントローラーを完全に取り除くことができます。

- (BOOL) hidesBottomBarWhenPushed { return YES; }

それがうまくいかない場合は、window.rootViewControllerを使用してゲームをプレイできます。起動時に、viewControllerを作成し、それをrootViewControllerにします。後でタブバーが必要になったときに、appDelegateにメッセージを返して、tabBarControllerを作成し、ビューを最初のviewControllerにします(そのまま!)。Xcodeタブバープロジェクトを使用して、簡単なデモアプリでこれを確認しました。これが私が使用したコードです:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];

    self.window.rootViewController = viewController1;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)switcher
{
    [viewController1.view removeFromSuperview];
    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;
}
于 2012-07-18T14:55:02.780 に答える
2

私が探していた答えを見つけました

これが他の誰かに役立つことを願っています

for(UIView *view in self.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, self.view.frame.size.height+49, view.frame.size.width, view.frame.size.height)];
        } 
        else 
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, self.view.frame.size.height)];
        }

    }
于 2012-07-18T14:57:39.800 に答える