swift - 根据 Xcode 目标进行导航

标签 swift cocoa-touch uitabbarcontroller ios-targets

我有一个带有 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/

相关文章:

ios - 标签栏 Controller 不显示栏按钮项目

ios - 如何在 swift 中进行条件转换

iOS 键盘颜色更改 - keyboardAppearance 深色不粘

swift - 如何在 Swift 中的数组中包含可选的

iphone - 触摸事件延迟

iphone - iPad : Problem changing the background color of Grouped TableView in iOS SDK 4. 2

swift - 无法更改 tabBar 内的选项卡(tabBar : didSelectItem item:)

iphone - 从不同的 UINavigationControllers ('More' 显示时 UITableview 改变高度

ios - Xcode无法运行iOS模拟器

swift - 简单的 Action 循环