Tabbar Implement page Jump (appdelegate +navigationviewcontroller + tabbarviewcontroller)

Source: Internet
Author: User

1. AppDelegate.h

Define Tabbarcontroller

#import <UIKit/UIKit.h>

@interface appdelegate:uiresponder <uiapplicationdelegate>

@property (Strong, nonatomic) uiwindow *window;

@property (Strong, nonatomic) uitabbarcontroller *tabbarcontroller;

@end

2.appdelegate.m

#import "AppDelegate.h"

#import "FirstViewController.h"

#import "SecondViewController.h"

#import "ThirdViewController.h"

@interface appdelegate () <uitabbarcontrollerdelegate>

@end

@implementation appdelegate

-(BOOL) application: (uiapplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions {

self. Window = [[uiwindow alloc]initwithframe: [[uiscreen mainscreen]bounds]];/ /Instantiate window

self. Window. backgroundcolor = [Uicolor whitecolor];//setting window background

_tabbarcontroller = [[Uitabbarcontroller alloc]init];//Instantiate tab Controller

_tabbarcontroller. Delegate = self;//Set Appdelegate as the proxy for the tab controller???

Instantiation of 3 controllers

Firstviewcontroller *firstviewcontroller = [[Firstviewcontroller alloc]initwithnibname: @ "Firstviewcontroller" bundle:nil];

Secondviewcontroller *secondviewcontroller = [[Secondviewcontroller alloc]initwithnibname :@ "Secondviewcontroller" bundle:nil];

Thirdviewcontroller *thirdviewcontroller = [[Thirdviewcontroller alloc]initwithnibname: @ "Thirdviewcontroller" bundle:nil];

Instantiate 3 navigators and place each controller's object in the Navigator's method with the controller

Uinavigationcontroller *navfirst = [[Uinavigationcontroller alloc] Initwithrootviewcontroller: Firstviewcontroller];

Navfirst. title = @ " take time ";

Uinavigationcontroller *navsecond = [[uinavigationcontroller alloc]initwithrootviewcontroller: Secondviewcontroller];

Navsecond. title = @ " Flower members ";

Uinavigationcontroller *navthird = [[Uinavigationcontroller alloc]Initwithrootviewcontroller : Thirdviewcontroller];

Navthird. title = @ " i ";

//Place the Navigator object in the sub-controller (viewcontroller) of the tab

_tabbarcontroller. Viewcontrollers = [nsarray Arraywithobjects:navfirst,navsecond,navthird, Nil];

//Set UIWindow Rootviewcontroller to Uitabbarcontroller

_window. Rootviewcontroller = _tabbarcontroller;

[self. Window makekeyandvisible];

return YES;

}

3. Set Tabbaritem title for each Uiviewcontroller

Firstviewcontroller.m

#import "FirstViewController.h"

#import "AppDelegate.h"

@interface firstviewcontroller () <uitableviewdatasource, uitableviewdelegate>{

Nsmutablearray *_allflowers;

}

@end

@implementation Firstviewcontroller

-(ID) initwithnibname: (NSString *) Nibnameornil Bundle: (nsbundle *) nibbundleornil{

Self = [super Initwithnibname:nibnameornil Bundle:nibbundleornil];

if (self) {

self. Tabbaritem. Image = [UIImage imagenamed:@ "First.png"];

self. Tabbaritem. Title = @ " take time ";

self. Navigationitem. Title = @ " take time ";

}

return self;

}

Tabbar Implement page jumps (appdelegate +navigationviewcontroller + tabbarviewcontroller)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.