我有一个带有 UITabBarController
的应用程序,选项卡照常导航,但其中一个选项卡应根据项目目标导航到不同的 View Controller ,所有内容均通过 Storyboard进行布局。
在加载 View Controller 之一时,如果不执行一些逻辑,似乎无法找到一种方法,这看起来很难看且不可扩展。
欢迎任何建议。
最佳答案
如果每个目标都有单独的 plist,您只需添加通过主包信息字典读取的自定义变量即可
p列表:
<key>NavigationType</key>
<string>Type1</string>
快速:
guard let navigationType = Bundle.main.infoDictionary?["NavigationType"] as? String else {
fatalError("Could not find navigation type in the plist")
}
switch navigationType {
case "Type1":
// do something
case "Type2":
// do another thing
....
关于swift - 根据 Xcode 目标进行导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41002528/