3 つのタブで構成されるアプリのルート コントローラーとしてタブ ビュー コントローラーを使用しています。ビュー A、ビュー B、ビュー C と呼びましょう。アプリが起動したらすぐにこれらのタブを読み込みたいのですが、 didFinishLaunchingWithOptions
機能ですが、正確にはわかりません。誰かがそれを行う方法を知っていますか?
ありがとう
3 つのタブで構成されるアプリのルート コントローラーとしてタブ ビュー コントローラーを使用しています。ビュー A、ビュー B、ビュー C と呼びましょう。アプリが起動したらすぐにこれらのタブを読み込みたいのですが、 didFinishLaunchingWithOptions
機能ですが、正確にはわかりません。誰かがそれを行う方法を知っていますか?
ありがとう
このような目的のために、私はこのアプローチを使用しました:
- (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
選択したタブでビューをプッシュ/ポップする必要がある場合は、 を作成します。上記の例では、1st
と3rd
タブのみが and を持っているUINavigationController
ので、それらで使用できself.navigationController pushViewController:
ます。