Ios addChildViewController视图未显示

Ios addChildViewController视图未显示,ios,uiviewcontroller,Ios,Uiviewcontroller,使用故事板,我试图将UIViewController覆盖在当前视图之上 在我的FirstViewController中,我导入SecondViewController.h,然后在viewDidLoad方法中运行以下命令 SecondViewController *overlay = [[SecondViewController alloc]init]; overlay.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.

使用故事板,我试图将
UIViewController
覆盖在当前
视图
之上

在我的
FirstViewController
中,我导入
SecondViewController.h
,然后在
viewDidLoad
方法中运行以下命令

SecondViewController *overlay = [[SecondViewController alloc]init];
overlay.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
[self addChildViewController:overlay];
[self.view addSubview:overlay.view];
[overlay didMoveToParentViewController:self];
[self.view bringSubviewToFront:overlay.view];
在我的
SecondViewController.h
viewDidLoad
方法中,我有一个到
NSLog
的输出,当我运行应用程序时,它会显示在控制台中,但是第二个视图不会显示在第一个视图的顶部。因此,
SecondViewController
正在添加,但未显示。我错过了什么

基本上,我希望
SecondViewController
具有透明的背景,这样我就可以执行一个显示信息的奇特警报消息,并且您仍然可以看到它后面的
FirstViewController


谢谢

首先设置secondViewController的标识符并使用简单代码:

secondViewController *overlay = [self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"];
overlay.view.frame = CGRectMake(100, 100, 100, 200);
[self.view addSubview:overlay.view];

在我的例子中,标识符与类名相同,即“secondViewController”。

谢谢。太明显了。最后,我找到了答案。