Uitabbarcontroller subclasses, Init and viewdidload order

Source: Internet
Author: User

Original address: http://www.andrewmonshizadeh.com/2015/02/23/uitabbarcontroller-is-different/

Today, a new subclass of Uitabbarcontroller was created, and the Uitabbarcontroller controller was ejected from a controller using a present method. It is strange that the viewdidload is called when the Init method is in the subclass controller, which results in the passing of the value of the viewdidload when it is loaded. Later read the above post, Uitabbarcontroller in the call "Super Init", The system definitely called the self.view thing, but at this point the view has not been loaded, so the system forced to call Viewdidload to load Self.view, finally loaded, and then go to the Init method of the IF (self) conditional statement. The specific article also said, in fact, Uitabbarcontroller in the init, will increase Uitabbar to Self.view, this time must be loaded self.view out, thus called Loadview, and then call Viewdidload, Viewwillappear and so on. This is the characteristic of Uitabbarcontroller.

Solution: Just do not write the loading interface code in Viewdidload and Viewwillappear methods, you can write a separate method, directly at the end of the init call. So my advice is to directly delete the Viewdidload and Viewwillappear methods, the loading interface is all written in Init, as follows:

-(instancetype) init
{self
    = [super init];
    if (self) {
        //load Interface
    }
    return self;
}

The following two methods can be directly shielded
//-(void) viewdidload
//{
//    [Super Viewdidload];
////    
}
//
//-(void) Viewwillappear: (BOOL) animated
//{
/    
///}

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.