我正在尝试在其上展示UIViewController
a UIView
。
以下是我在我的viewDidLoad
方法中尝试的代码。
//create the view controller
UIViewController *controller = [[UIViewController alloc] init];
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor whiteColor];
controller.view = view;
//show the view
[self presentViewController:controller animated:YES completion:nil];
当我运行该应用程序时,它给了我以下错误。
Warning: Attempt to present <UIViewController: 0x751fcd0> on <ViewController: 0x751d7a0> whose view is not in the window hierarchy!
这是什么意思,我哪里错了?它不应该显示白色视图还是我理解错误?
谢谢。