0

このチュートリアルに従って、カスタムUITabBarControllerを使用してカスタムを正常に作成および実装しました。非表示にするまでは問題なく動作します。UITabBar

私は Storyboards や IB を使用しておらずUITabBarController、カスタムを非表示にするために画面上にある既存のものへの参照を取得する必要がありUIViewます。私はこのようにしようとしていますが、それはその新しいインスタンスを作成するだけでUITabBarControllerあり、画面に表示される元のインスタンスを指していません:

SGTabBarController *tabBarController = [[SGTabBarController alloc] init];
[tabBarController hideCustomTabBar];

SGTabBarController.h

@interface SGTabBarController : UITabBarController

@property (nonatomic) int tabBarHeight;

-(void)hideCustomTabBar;
-(void)showCustomTabBar;

@end

SGTabBarController.m

-(void)hideCustomTabBar{
    customTabBarView.hidden = YES;
    NSLog(@"HIDDEN!!!");
}

-(void)showCustomTabBar{
    customTabBarView.hidden = NO;
}

それに到達する方法についてのアイデアはありますか?前もって感謝します!

4

1 に答える 1

1

アプリ内のどこからでもカスタムUITabBarControllerにアクセスする方法。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Set up the Dashboard
//
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[_window makeKeyAndVisible];

UITabBarController *tabBarController = [[UITabBarController alloc] init];
NSMutableArray *tabBarItems = [@[] mutableCopy];

// Repeat this for any amount of ViewControllers
UITableViewController *tableViewController = [UITableViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *navController = [UINavigationController alloc] initWithRootViewController:tableViewController];

[tabBarItems addObject:navController];
tabBarController.viewControllers = tabBarItems;
self.window.rootViewController = tabBarController;

return YES;
}
于 2013-03-07T18:22:59.703 に答える