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

时间:2018-03-05 10:00:10

标签: swift xcode viewcontroller iboutlet

我的故事板中有多个ViewControllers,我需要故事板中的各种对象链接到代码中的变量。

我的ViewControllers的屏幕截图

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

代码我正在尝试关联

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 {

}

2 个答案:

答案 0 :(得分:2)

确保为每个视图控制器指定了正确的“自定义类”。

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

像这样:

Correct

答案 1 :(得分:0)

将要连接的UIView类与故事板中的UIView链接。

相关问题