2

3 つのタブで構成されるアプリのルート コントローラーとしてタブ ビュー コントローラーを使用しています。ビュー A、ビュー B、ビュー C と呼びましょう。アプリが起動したらすぐにこれらのタブを読み込みたいのですが、 didFinishLaunchingWithOptions機能ですが、正確にはわかりません。誰かがそれを行う方法を知っていますか?

ありがとう

4

1 に答える 1

0

このような目的のために、私はこのアプローチを使用しました:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window = window;

    UITabBarController *tabBarController = [[UITabBarController alloc] init];

    rootView = [[SGMenuViewController alloc] init];

    UIViewController *tab1VC = [[UIViewController alloc] init];
    UIViewController *tab2VC = [[UIViewController alloc] init];
    UIViewController *tab3VC = [[UIViewController alloc] init];
    UIViewController *tab4VC = [[UIViewController alloc] init];

    navController = [[UINavigationController alloc] initWithRootViewController:rootView];
    UINavigationController *secondNavController = [[UINavigationController alloc] initWithRootViewController:tab3VC];

    NSArray* controllers = [NSArray arrayWithObjects:navController, tab2VC, secondNavController, tab4VC, nil];
    tabBarController.viewControllers = controllers;

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}

基本的に を作成しUITabBarController、そこにすべてのビューを配置します。UINavigationController選択したタブでビューをプッシュ/ポップする必要がある場合は、 を作成します。上記の例では、1st3rdタブのみが and を持っているUINavigationControllerので、それらで使用できself.navigationController pushViewController:ます。

于 2013-03-15T14:59:23.470 に答える