FirstApp,iphone开发学习总结0,创建TabBar

在FirstAppAppDelegate.m的添加文件引用

#import "ImageViewController.h"
#import "TableViewController.h"
#import "ButtonViewController.h"
#import "TextFieldViewController.h"
#import "NavViewController.h"

在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

中添加TabBarController以及NavigationController。
    UITabBarController *tabController = [[UITabBarController alloc] init];

    ImageViewController *imgTab = [[ImageViewController alloc] init];
    TableViewController *tableTab = [[TableViewController alloc] init];
    ButtonViewController *btnTab = [[ButtonViewController alloc] init];
    TextFieldViewController *textTab = [[TextFieldViewController alloc] init];
    
    NavViewController *navTab = [[NavViewController alloc] init];
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:navTab];
    
    NSArray *tabArray = [[NSArray alloc] initWithObjects:imgTab, tableTab, btnTab, textTab, navigation, nil];
    
    [navigation release];
    [imgTab release];
    [tableTab release];
    [btnTab release];
    [textTab release];
    [navTab release];
    
    [tabController setViewControllers:tabArray];
    [tabArray release];
    
    [self.window setRootViewController:tabController];
    [tabController release];

 

所表达的是:第5个(NavView页面)创建了NavigationConroller,如果其他页面需要,可以类似这样创建。

没有经验的伤不起啊,求指点更好的方法。

posted @ 2012-05-03 22:18  Maxfong  阅读(333)  评论(0编辑  收藏  举报