简体   繁体   中英

viewwillappear and viewdidappear not called in Xcode 9

I have an iPad app where I add a Landingviewcontroller to a navigationcontroller and add this navigationcontroller to window's rootviewcontroller. I used to perform few actions in LandingviewController's viewwillappear. But, suddenly in Xcode9 it stopped calling. Here is my code -

- (void) applicationDidFinishLaunching: (UIApplication *) application {

     self.landingPageController = [[LandingPageViewController alloc] init];
     self.introViewController = [[UINavigationController alloc] initWithRootViewController:self.landingPageController];

    _window.rootViewController = self.introViewController;
    [_window makeKeyAndVisible];
}

ViewDidAppear and ViewWillAppear methods are not called in LandingPageViewController .

Any idea why are these methods are not getting called?

EDIT: Added viewDidAppear and ViewWillAppear methods

-(void)viewWillAppear:(BOOL)animated{

   [super viewWillAppear:animated];

   [self.navigationController setNavigationBarHidden:YES animated:YES];

   [self setupCoverView];

 }

-(void)viewDidAppear:(BOOL)animated {

   [super viewDidAppear:animated];
    // load news view controller
    [self news:userChanged]; 
 }

Replace

  _window.rootViewController = self.landingPageController;

with

  _window.rootViewController = self.introViewController;

Navigation controller should be your rootviewcontroller in your case!

Targets Deployment config

check your targets config,delete value of Main Interface,then add code at begin of didFinishLaunchingWithOptions。 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM