Tag: uistoryboard presentviewcontroller

如何以编程方式调用View Controller?

我已经看过了我能find的所有教程,但我仍然没有答案。 我需要从代码调用另一个视图。 我正在使用UIStoryboards 。 我已经通过从UIButtons拖拽来多次改变视图,但是现在它必须来自代码。 我试图从主菜单调用信息页,如果这是用户第一次打开应用程序。 但是,我似乎无法find从代码中更改视图的方法。 我的所有视图都由相同的文件( ViewController2 )控制。 我的主菜单的identifier是ViewControllerMain ,信息页面的identifier是ViewControllerInfo 。 首先我试过这个: [ViewControllerMain presentViewController: ViewControllerInfo animated:YES completion: NULL]; 然后我试着为每个UIViewControllers做不同的UIViewControllers ,并说: [ViewController2 presentViewController: ViewController animated:YES completion: NULL]; 都没有工作。 对于第一个,它说: 使用未声明的标识符ViewControllerMain。 在第二个,它说: 意外的接口名称“ViewController”:预期的标识符。 我能做什么?