标签视图控制器

新建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.csdn.net/detail/cloud95/5187356

你可能感兴趣的:(标签视图控制器)