Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0

网上大部分的答案都是把项目切换到 iOS 9.0,的确可以解决这个问题,但是如果项目有需求要支持9.0以下的系统我们还想使用 Storyboard References 该怎么整呢?

在上这哥们给出了答案 http://www.jianshu.com/p/fd3f2df8f6a8 不过里面就给了一个日本哥们链接,没说具体的步骤,开始我看到那个日本哥们的操作没怎么看懂(大学日语白学了),后来仔细研究了一下,给一下具体的步骤。

  1. 新建一个项目 干掉系统默认的控制器,拖一个新的TabBarController


    Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0_第1张图片
    Snip20170702_3.png

2.把TabBarController关联的两个ViewController拆分成连个Storyboard

Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0_第2张图片
Snip20170702_4.png

编译运行一下没什么问题,就不贴图了。

3.把项目最低版本改成8.0,然后在编译一下

Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0_第3张图片
Snip20170702_7.png

完美报错

4.要解决问题我需要新建一个继承TabBaController的控制器MainController与我们的Main.storyboard的TabBaController控制器产生关联

Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0_第4张图片
Snip20170702_8.png

5.关键的两步,首先在MainController加入载入两个Storyboard的代码,直接copy日本哥们代码简单改了一下3.0的语法

Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0_第5张图片
Snip20170702_11.png

class MainController: UITabBarController {

override func viewDidLoad() {
    super.viewDidLoad()
    
    let firstViewStoryboard = UIStoryboard(name: "First", bundle: Bundle.main)
    let secondViewStoryboard = UIStoryboard(name: "Second", bundle: Bundle.main)
    
    let firstViewController = firstViewStoryboard.instantiateInitialViewController()
    let secondViewController = secondViewStoryboard.instantiateInitialViewController()
    
    self.viewControllers = [firstViewController!, secondViewController!]
}

}

然后最关键的把Main.storyboard里面Storyboard关联线干掉


Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0_第6张图片
Snip20170702_10.png

Command + r 完美运行

虽然日语不好但是差不多看懂了那个日本哥们的意思,就是通过代码建立 Storyboard References 的关系,干掉系统默认的 Storyboard References 的关系

技术拙劣,有不足和错误之处希望指出。

你可能感兴趣的:(Storyboard References cannot be the destinations of relationship segues prior to iOS 9.0)