添加子视图时无法修改视图元素

Unable to Modify View Elements when Adding a SubView

背景:

我有 4 个 .XIB 文件,它们以编程方式初始化为子视图,通过 self.view.addSubview(UIView) 方法调用到屏幕。

    //Initialize Associate Degree Selection UIView and prepare contraints
    degreeAuditAssociatesView = instanceFromNib(XIBFilename: "degreeAuditAssociate")
    degreeAuditAssociatesView?.frame = self.view.bounds
    degreeAuditAssociatesView?.autoresizingMask = [UIViewAutoresizing.flexibleWidth,UIViewAutoresizing.flexibleHeight]
    loadSavedCheckboxes()

    //Initialize Associate Degree Selection Results UIView and prepare contraints
    degreeAuditAssociatesViewResults = instanceFromNib(XIBFilename: "degreeAuditAssociateResults")
    degreeAuditAssociatesViewResults?.frame = self.view.bounds
    degreeAuditAssociatesViewResults?.autoresizingMask = [UIViewAutoresizing.flexibleWidth,UIViewAutoresizing.flexibleHeight]

    //Initialize Bachelors Degree Selection UIView and prepare contraints
    degreeAuditBachelorsView = instanceFromNib(XIBFilename: "degreeAuditBachelors")
    degreeAuditBachelorsView?.frame = self.view.bounds
    degreeAuditBachelorsView?.autoresizingMask = [UIViewAutoresizing.flexibleWidth,UIViewAutoresizing.flexibleHeight]
    loadSavedCheckboxes()

    //Initialize Bachelors Degree Selection Results UIView and prepare contraints
    degreeAuditBachelorsViewResults = instanceFromNib(XIBFilename: "degreeAuditBachelorsResults")
    degreeAuditBachelorsViewResults?.frame = self.view.bounds
    degreeAuditBachelorsViewResults?.autoresizingMask = [UIViewAutoresizing.flexibleWidth,UIViewAutoresizing.flexibleHeight]

当我调用 self.view.addSubview(degreeAuditBachelorsViewResults!) 时,视图会正确显示此 XIB UIView 并相应地填充所有文本框和显示元素。

问题: 当我调用 self.view.addSubview(degreeAuditAssociatesViewResults!)(第二个代码块)时,视图显示此 XIB UIView 但 WITHOUT 填充文本中的任何数据-boxes.

有什么奇怪的 当我删除代码并且从不初始化第四个 UIView(第四个代码块)(degreeAuditBachelorsViewResults)时,degreeAuditAssociateResults UIView 加载没有问题。

当我在代码块中移动时,(块 2)或(块 4)没有显示所有填充有信息的文本元素。我感觉跟addSubview(UIView)方法和不接受任何信息有关。

请帮忙,我 运行 别无选择。

此问题供日后参考。如果两个视图具有相同的引用出口并且正在从 XIB 文件以编程方式初始化。最后初始化的 UI 视图将连接参考插座。如果可能,每个视图都应引用其单独的插座。