标签视图控制器

本文详细介绍如何在iOS中创建带有三个视图控制器的Tabbed应用程序。从新建项目开始,逐步介绍如何设置和配置UITabBarController,以及如何为每个Tab自定义ViewController。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

新建Tabbed application,名为Tabview

新建一个viewController

修改AppDelegate.m

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

{

    self.window = [[[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]]autorelease];

    // Override point for customization after application launch.

   UIViewController *viewController1 = [[[FirstViewControlleralloc] initWithNibName:@"FirstViewController"bundle:nil]autorelease];

   UIViewController *viewController2 = [[[SecondViewControlleralloc] initWithNibName:@"SecondViewController"bundle:nil]autorelease];

    ThirdViewController *vc3 =[[[ThirdViewControlleralloc] init] autorelease];

    self.tabBarController = [[[UITabBarControlleralloc] init]autorelease];

   self.tabBarController.viewControllers =@[viewController1, viewController2,vc3];

    self.window.rootViewController =self.tabBarController;

    [self.windowmakeKeyAndVisible];

    return YES;

}

修改ThirdViewController.m

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

   self = [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];

   if (self) {

        // Custom initialization

       self.title =@"第三个";

        self.tabBarItem.image = [UIImageimageNamed:@"second"];

    }

    return self;

}


源码地址:http://download.youkuaiyun.com/detail/cloud95/5187356

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值