IOS appdelegate Settings Root page

Source: Internet
Author: User
Tags uikit

1. The simplest only one controller of the root page (without the default storyrboard)

Appdelegate.m

#import "AppDelegate.h"

#import "KCMainViewController.h"

@interface appdelegate ()

@end

@implementation appdelegate

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

self. Window = [[uiwindow alloc]initwithframe: [[UIScreen mainscreen] bounds]];

Kcmainviewcontroller *mainview = [[Kcmainviewcontroller alloc]initwithnibname:@ "Kcmainviewcontroller" bundle:nil];

_window. Rootviewcontroller = MainView;

[_window makekeyandvisible];

return YES;

}

2. Root page of multiple controllers set with navigation

1) AppDelegate.h

#import <UIKit/UIKit.h>

@interface appdelegate:uiresponder <uiapplicationdelegate>

@property (Strong, nonatomic) uiwindow *window;

@property (Strong, nonatomic) uinavigationcontroller *navigationcontroller;

@end

2) APPDELEGATE.M

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

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

self. Window. backgroundcolor = [Uicolor whitecolor];

Registerviewcontroller *masterviewcontroller = [[Registerviewcontroller alloc]initwithnibname :@ "Registerviewcontroller" bundle:nil];

_navigationcontroller = [[uinavigationcontroller alloc]initwithrootviewcontroller: Masterviewcontroller];

[_window addsubview: _navigationcontroller. View];

[self. Window makekeyandvisible];

}

Here to say a little more page jump things, if used navigation, is the agent of the Navigationcontroller Pushviewcontroller method to put the new controller into the navigation stack, the use of "last first out" principle, Toggles the page.

3. Setting up the root controller with Tabbar

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

self. Window = [[uiwindow alloc] initwithframe: [[UIScreen mainscreen] bounds]];

Ggtabbarcontroller *tabbar = [[Ggtabbarcontroller alloc] init];

TestViewController1 *vc1 = [[TestViewController1 alloc] init];

Vc1.tabBarItem.title = @ " take time";??

Vc1.tabBarItem.badgeValue = @ "12";

TestViewController2 *VC2 = [[TestViewController2 alloc] init];

TestViewController3 *vc3 = [[TestViewController3 alloc] init];

TabBar. viewcontrollers = @[vc1, VC2, Vc3];

self. Window. Rootviewcontroller = TabBar;

self. Window. backgroundcolor = [Uicolor whitecolor];

[self. Window makekeyandvisible];

return YES;

}

IOS appdelegate Settings Root page

Related Article

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.