Programmatically set the initial view controller using Storyboards

前端 未结 22 2221
感情败类
感情败类 2020-11-22 15:00

How do I programmatically set the InitialViewController for a Storyboard? I want to open my storyboard to a different view depending on some condition which may

22条回答
  •  渐次进展
    2020-11-22 15:20

    UPDATED ANSWER for iOS 13 and scene delegate:

    make sure in your info.plist file you go into Application Scene Manifest -> Scene Configuration -> Application Session Role -> Item 0 and delete the reference to the main storyboard there as well. Otherwise you'll get the same warning about failing to instantiate from storyboard.

    Also, move the code from the app delegate to the scene delegate method scene(_:willConnectTo:options:), since this is where life cycle events are handled now.

提交回复
热议问题