为什么 IBOutlets 只响应多个视图控制器之一?

Why do IBOutlets only respond to one of the multiple view controllers?

我的情节提要中有多个 ViewController,我需要情节提要中的各种对象 link 到代码中的变量。

我的 ViewControllers 的屏幕截图

我只能从我最初开始的 ViewController 按住 Ctrl 并拖动 IBOutlet,更改故事入口点不会影响问题。

我正在尝试的代码 link

import UIKit

class ViewController: UIViewController {



    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view typically from a    nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @objc func didTapButton(_ tap: UITapGestureRecognizer) {

    }
}

extension ViewController: UIViewControllerTransitioningDelegate {

}

Link UIView class 你想连接故事板中的 UIView。

确保您为每个视图控制器指定了正确的"Custom Class"。

也就是说,将 ViewController 设置为每个视图控制器的自定义 class。

像这样: