`
jishublog
  • 浏览: 871323 次
文章分类
社区版块
存档分类
最新评论

UITabBarController的简单使用

 
阅读更多

不啰嗦理论方面的内容,下面直接上代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]]autorelease];
    
    /* UITabBarController的简单使用 */
    if (self.tabBarController == nil) {
       self.tabBarController = [[[UITabBarControlleralloc] init]autorelease];
    }
   // 实例化标签栏控制的子视图控制器
    FirstViewController *firstVC = [[FirstViewControlleralloc] initWithNibName:nilbundle:nil];
    SecondViewController *secondVC = [[SecondViewControlleralloc] initWithNibName:nilbundle:nil];
   self.tabBarController.viewControllers = [NSArrayarrayWithObjects:firstVC,secondVC, nil];
    self.window.rootViewController = self.tabBarController;
    // 定制标签栏按钮
   UITabBarItem *item1 = [[UITabBarItemalloc] initWithTitle:@"FirstVC"image:nil tag:101];
   UITabBarItem *item2 = [[UITabBarItemalloc] initWithTitle:@"SecondVC"image:nil tag:102];
    firstVC.tabBarItem = item1;
    secondVC.tabBarItem = item2;
    // 释放alloc出来的对象
    [firstVCrelease];
    [secondVCrelease];
    [item1release];
    [item2release];
    
    [self.windowmakeKeyAndVisible];
    returnYES;
}





分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics