IOS, view controller related (Uiviewcontroller)

Source: Internet
Author: User

1. View Controller individual method call timing

2. tab (tab bar) and navigation bar (Navigation bar)

View Controller individual method call timing

Init: Method

Instantiate the necessary objects in the Init method (following the Lazyload thought) Init method initializes the Viewcontroller itself Loadview: Method This is when the nib View page is not being used, and the subclass will create its own custom view layer. You must not call Viewdidload directly: The method is called after the view is loaded viewwillappear: Call Viewdidappear When the method view is about to be visible: Method video calls Viewwilldisappear when it transitions completely to the screen: Method view is dismissed when called, overwritten or otherwise hidden viewdiddisappear: Method View is dismissed after calling, overwriting or otherwise hidingwhen a view is switched to B view, the sequential processViewdidload of the 1.B viewViewwilldisappear of the 2.A viewViewwillappear of the 3.B view4.A View Viewdiddisappear5.B View Viewdidappear tabs (tab bar) and navigation bar (Navigation bar)

AppDelegate.h file

#import <UIKit/UIKit.h>

@interface Appdelegate:uiresponder <UIApplicationDelegate>

@property (Strong, nonatomic) UIWindow *window;

@property (strong,nonatomic) uitabbarcontroller *tabbarcontroller;//Bottom Tab Controller

@end

APPDELEGATE.M file

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {

Self.window=[[uiwindow Alloc]initwithframe:[[uiscreen Mainscreen] bounds];

Message Controller

Messageviewcontroller *msgcontroller=[[messageviewcontroller alloc] init];

Uinavigationcontroller *navmsg=[[uinavigationcontroller alloc] Initwithrootviewcontroller:msgcontroller];

The picture style of the//tab is handled this way to prevent the picture from being completely displayed

Uitabbaritem *msgtabitem = [[Uitabbaritem alloc]initwithtitle:@ ' message ' image:[[uiimage imagenamed:@ ' [email protected] ' Imagewithrenderingmode:uiimagerenderingmodealwaysoriginal] selectedimage:[[uiimage imageNamed:@ "[email protected] [] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]];

Navmsg.tabbaritem=msgtabitem;

Contact Controller

Contactviewcontroller *concontroller=[[contactviewcontroller alloc] init];

Uinavigationcontroller *navcon=[[uinavigationcontroller alloc] Initwithrootviewcontroller:concontroller];

Uitabbaritem *contabitem = [[Uitabbaritem alloc]initwithtitle:@ ' contacts ' image:[[uiimage imagenamed:@ ' tab_ [email Protected] "imagewithrenderingmode:uiimagerenderingmodealwaysoriginal] selectedimage:[[uiimage imageNamed:@" tab_ [email protected] [] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]];

Navcon.tabbaritem=contabitem;

Dynamic Controller

Dynamicviewcontroller *dyncontroller=[[dynamicviewcontroller alloc] init];

Uinavigationcontroller *navdyn=[[uinavigationcontroller alloc] Initwithrootviewcontroller:dyncontroller];

Uitabbaritem *dyntabitem = [[Uitabbaritem alloc]initwithtitle:@ "dynamic" Image:[[uiimage imagenamed:@ "tab_ [email protected ] "] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal] selectedimage:[[uiimage imageNamed:@" tab_ [email protected] [] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];

Navdyn.tabbaritem=dyntabitem;

Self.tabbarcontroller=[[uitabbarcontroller alloc] init];

[Email protected] [Navmsg,navcon,navdyn];

self.tabbarcontroller.selectedindex=0;

Since the iphone is a single-window program, there is only such a Windows object, and it is UIWindow, not nswindow. And according to the document: This is a convenient way to make the main window of the object being used appear to the front of the screen.

[Self.window makekeyandvisible];

return YES;

}

IOS, view controller related (Uiviewcontroller)

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.