【问题标题】:Navigation depending on Xcode target导航取决于 Xcode 目标
【发布时间】:2017-04-21 12:21:41
【问题描述】:

我有一个带有UITabBarController 的应用程序,选项卡照常导航,但其中一个选项卡应根据项目目标导航到不同的视图控制器,所有内容都使用故事板布局。

在加载其中一个视图控制器时,如果不执行一些逻辑,似乎无法找到一种方法,这看起来很丑陋且不可扩展。

欢迎任何建议。

【问题讨论】:

  • this 呢?
  • @Ryan 很好,但找不到与触摸标签栏项目以进行导航以及根据目标导航到不同位置的事实相关的任何内容。

标签: swift cocoa-touch uitabbarcontroller ios-targets


【解决方案1】:

如果您对每个目标都有单独的 plist,您只需添加一个自定义变量,您可以通过主捆绑信息字典读取该变量

列表:

<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
    ....

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-17
    • 2012-12-13
    • 1970-01-01
    • 2015-03-27
    • 2016-04-25
    相关资源
    最近更新 更多