iOS 5 storyboard, programmatically determine path

后端 未结 3 706
故里飘歌
故里飘歌 2020-12-07 18:18

I\'m having trouble to achieve the following using a storyboard:

When setup is not done: run app -> show settings view controller -> show main navigation controller

3条回答
  •  暖寄归人
    2020-12-07 18:37

    I did something similar to amoshaviv, his advice is sound. I did it slightly different though, and I'll give some more info. I created a custom MyInitialViewController class, derived from UIViewController, and made this the initial view controller. In the storyboard file, I created modal segues with appropriate names to all (in my case three) possible 'real' first view controllers. In the MyInitialViewController class, I implemented the

    - (void)viewDidAppear:(BOOL)animated;
    

    method, to first perform the check which view to switch to, and then do the correct

    [self performSegueWithIdentifier:@"NameOfSegue" sender:self];
    

    Effectively, this makes the MyInitialViewController nothing more than a switch performed when it's brought into view. I first tried doing this when loaded because I don't care for actually seeing this view, but that did not work, while viewDidAppear does.

    To make this visually smooth, I tried the following. In the properties of the segues, I disabled animation. The view I left empty, and I gave it a background color matching to that of the startup image.

提交回复
热议问题