在Xcode 9

时间:2017-09-26 13:29:22

标签: ios objective-c iphone ipad xcode9

我有一个iPad应用程序,我将一个Landingviewcontroller添加到一个navigationcontroller,并将这个navigationcontroller添加到window的rootviewcontroller中。我曾经在LandingviewController的viewwillappear中执行一些操作。但是,突然在Xcode9中它停止了呼叫。这是我的代码 -

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

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

    _window.rootViewController = self.introViewController;
    [_window makeKeyAndVisible];
}
LandingPageViewController 中未调用

ViewDidAppear ViewWillAppear 方法。

知道为什么这些方法没有被调用?

编辑:添加了viewDidAppear和ViewWillAppear方法

-(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]; 
 }

2 个答案:

答案 0 :(得分:1)

替换

  _window.rootViewController = self.landingPageController;

  _window.rootViewController = self.introViewController;
在你的情况下,

Navigation controller应该是你的rootviewcontroller

答案 1 :(得分:0)

Targets Deployment config

检查目标配置,删除主界面的值,然后在didFinishLaunchingWithOptions开头添加代码。 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]