iOS Development UI Chapter-uitabbarcontroller Lifecycle (built with Storyoard)

Source: Internet
Author: User

iOS Development UI Chapter-uitabbarcontroller Lifecycle (built with Storyoard)First, Uitabbarcontroller in the Storyoard to build 1. Create a new project, remove the default controller from storyboard, and drag UITab Bar controller. 2. Create the Viewcontroller and add to the UITab Bar controller (Wired). Note: The order of the lines is the order of the future display, shown in front of the first line of view. Tip: The Controller interface corresponds to the Tabbarbutton and the picture shows what content is determined by its controller. 3. Set the Uitabbar and other information of the sub-controller. 4. Running effect two, Uitabbarcontroller life cycle demonstration idea: New three controller class to manage the controller separately, rewrite internal life cycle method can understand Uitabbarcontroller internal management mechanism. Analysis Code:
1 #import "TXAppDelegate.h"2 3 @implementationtxappdelegate4 5 /**6 * Called when the app has finished loading (usually only once)7  *8  */9-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) LaunchoptionsTen { OneNSLog (@"didfinishlaunchingwithoptions"); A     returnYES; - } -  the /** - * Called when the app loses focus (UI controls are not working properly) -  */ -- (void) Applicationwillresignactive: (UIApplication *) Application + { -NSLog (@"applicationwillresignactive"); + } A  at /** - * Call when app goes backstage (app disappears) -  */ -- (void) Applicationdidenterbackground: (UIApplication *) Application - { -NSLog (@"Applicationdidenterbackground"); in } -  to /** + * The app is called when it comes to the foreground (app display) -  */ the- (void) Applicationwillenterforeground: (UIApplication *) Application * { $NSLog (@"Applicationwillenterforeground");Panax Notoginseng } -  the /** + * Called when the app gets focus (this time the entire app's UI controls are working) A  */ the- (void) Applicationdidbecomeactive: (UIApplication *) Application + { - //Uitabbarcontroller *TABBARVC = (Uitabbarcontroller *) Self.window.rootViewController; $ //NSLog (@ "%@", Nsstringfromcgrect (TabbarVc.tabBar.frame)); $      - //For (UIView *child in tabbarVc.tabBar.subviews) { - //if ([Child Iskindofclass:[uiimageview class]]) { the //[Child Removefromsuperview]; - //        }Wuyi //    } theNSLog (@"applicationdidbecomeactive"); - } Wu  - //app goes backstage: Hibernate, can't accept things (such as close) About /** $ * Call when app is closed (normally not called) -  */ -- (void) Applicationwillterminate: (UIApplication *) Application - { ANSLog (@"applicationwillterminate"); + } the  - @end

(1) Run the program, the printout is: note: When the three sub-controllers are added to Uitabbarcontroller to manage, when the program starts it will only load the first added controller view. (2) Click the contact button to switch to the second interface. The printout is: Description: Move the first view away and add the new view, but the first view is not destroyed. (3) Re-click the message interface, printed as follows: Note: First re-switch to the message interface, the one controller will be displayed directly, no load proof (2) After the first view is removed and not destroyed (because its controller is still there, there is a strong reference to it), And the view of the other is removed and not destroyed. No matter how you switch, the controller and view will not be destroyed. Uinavigationcontroller and Uitabbarcontroller are managed by a stack, one through an ordinary array. Supplementary note: The actual height of the Uitabbar in Uitabbarcontroller is 49. In the following method of application, print the Uitabbar frame for viewing.

Printing results are:

iOS Development UI Chapter-uitabbarcontroller Lifecycle (built with Storyoard)

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.