从忽略约束的代码加载故事板

Storyboard loaded from code ignoring constraints

我有一个带有约束的故事板构建视图,通过 IB 加载时看起来很棒。当我尝试从代码加载相同的视图时,该视图看起来已正确放置在视图中,但我的所有约束都已关闭,并且在编辑时我看不到模拟器中的更改。

这是我用来加载视图的代码 -

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Pop" bundle:nil];
    UIViewController *vc = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"FreshPopViewController"];

    firstPopView = vc.view;
    vc.view = nil;

    //firstPopView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    //[firstPopView setFrame:self.view.frame];
    [firstPopView setFrame:self.view.bounds];

    UIButton *requestButton = (UIButton*)[self.view viewWithTag:101];

    [requestButton addTarget:self action:@selector(newRequestButtonClicked) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:firstPopView];

正如您在代码中看到的那样,我尝试了不同的方法来设置框架,但这似乎没有什么不同。

我能够通过在 VC 的视图和我的所有对象之间添加一个包含视图来解决这个问题。我不必在代码中编辑任何内容,只需在 IB 中重新对这个新视图进行约束。