您的位置:首页 > 移动开发

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

2012-05-03 22:18 453 查看
在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,如果其他页面需要,可以类似这样创建。

没有经验的伤不起啊,求指点更好的方法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: