雖然我不知道什麼是最有效的「是指在你的情況下,我會盡力解釋3.解釋什麼,我通常會做,當談到典型的TabBar應用:
我不要參加示例項目,因爲對於所有那些IB的東西來說(對我來說)有太多的魔力(並且我嘗試過將Tabbar控制器和導航控制器結合在一起)。
我剛剛成立了一個簡單的項目,擺脫所有IB的東西,做這樣的事情在應用程序委託:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSMutableArray *cons = [[NSMutableArray alloc ]init];
viewController = [[UITabBarController alloc] init];
int i = 0;
UIViewController *firstController = [[SomeViewViewControllerClazz alloc] init];
firstController = [[UITabBarItem alloc]initWithTitle:@"Een" image:nil tag:i];
[cons addObject:firstController];
[firstController release];
i++;
UIViewController *secondController = [[AnotherViewControllerClazz alloc] init];
secondController = [[UITabBarItem alloc]initWithTitle:@"Twej" image:nil tag:i];
[cons addObject:secondController];
[secondController release];
i++;
UIViewController *thirdController = [[WhateverViewControllerClazz alloc] init];
thirdController = [[UITabBarItem alloc]initWithTitle:@"Drej" image:nil tag:i];
[cons addObject:thirdController];
[thirdController release];
i++;
viewController.viewControllers = cons;
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
這樣,我有最大的自由做任何我想做的與控制器但也有內置tabbars的力量。
1 .:這樣,我從來沒有記憶問題,即使我在開始時加載控制器。 2 .:如果tabbar的想法適合您的應用程序,請使用它作爲iOs提供它。
感謝您的評論! :) –