本文介绍了以编程方式创建和呈现模态视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图以编程方式从使用情节提要启动的视图控制器中声明模式视图控制器.我希望看到一个空白视图,但是我只能从第一个控制器看到webview.
I am trying to programmatically declare a modal view controller from a view controller launched using storyboard. I would expect to see a blank view coming up but instead I only see the webview from the first controller.
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *fullURL = @"http://google.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
_viewWeb.delegate=self;
[_viewWeb loadRequest:requestObj];
modalViewController=[[UIViewController alloc] init];
[self presentViewController:modalViewController animated:YES completion:nil];
}
推荐答案
您这样做太早了. viewDidLoad
中尚无界面.将该代码放入viewDidAppear:
中,然后看看会发生什么.
You're doing this too soon. There's no interface yet, in viewDidLoad
. Put that code into viewDidAppear:
instead, and see what happens.
这篇关于以编程方式创建和呈现模态视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!