2011-10-31 50 views
-1

Hihi全部,iphone - Tabbar使用

我想在我的iphone應用程序中使用tabbar控件,我有幾個關於控制的查詢。

  1. 如果我創建的TabBar模板項目,在我的應用程序委託,它推出的應用程序時加載所有5個選項卡控制器,這會導致內存使用的任何低效率?

  2. 實際上我可以將tabbar控件拖動到我的每個屏幕中,並通過[self presentedViewController ..]和[self dismissModalViewControllerAnimated ...]方法在屏幕之間手動切換?

  3. 什麼是在iPhone應用程序中使用tabbar最有效的方式?

在此先感謝!

:)

回答

0

雖然我不知道什麼是最有效的「是指在你的情況下,我會盡力解釋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提供它。

+0

感謝您的評論! :) –

0

您的查詢的答案是:

  1. 不,這不會造成內存使用的任何低效率。但你應該釋放標籤欄控制器

  2. 您可能會這樣做,但它不是很好的做法,當您撥打presentedViewController選項卡將會消失(對不適當的術語抱歉)。

  3. 在iphone應用程序中使用tabbar最有效的方式是採取一個tabbar控制器並添加該tabBar視圖。
+0

感謝您的評論! –

+0

你是最受歡迎的.... :) –