Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create and Present modal view controller programmatically

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];
}
like image 979
DD. Avatar asked Dec 21 '22 07:12

DD.


1 Answers

You're doing this too soon. There's no interface yet, in viewDidLoad. Put that code into viewDidAppear: instead, and see what happens.

like image 120
matt Avatar answered Feb 01 '23 23:02

matt