Question

I have one UIViewController subclass called ThemeView. When I click on 1 button, it initiates an instance of a second UIViewController subclass called ViewJeuSolo and displays it.

-(IBAction) boutonJouer:(id)sender{

    //Do something

    ViewJeuSolo *secondViewController =
    [self.storyboard instantiateViewControllerWithIdentifier:@"ViewJeuSolo"];


    [self.navigationController pushViewController:secondViewController animated:YES];

}

So this works. My issue: there is a WebView in ViewJeuSolo and I want to show a spinner, load the WebView and after that do the

[self.navigationController pushViewController:secondViewController animated:YES];

I already have a

- (void)webViewDidFinishLoad:(UIWebView *)wva

But I can't see how to connect this function to my previous view.

Summary: I want to switch view only when the WebView in the new view has loaded.

Was it helpful?

Solution 3

For people who have the same issue,i do this:

Put all the fonction for load the webview in you're first view. When you need to change view, load the web view in hidde and show the spinner. When the web view was load, init the next view and give the webview by a setwebview() function.

Is work fine for me :). If you need more precision, tell me. Thanks all for you're help.

OTHER TIPS

What you are trying to do is not possible - you are going to have to load the UIWebView based view (here secondViewController) and then display the "Please Wait" loading message until the delegate webViewDidFinishLoad is called.

One thing you could do is to present a UIView based loading screen from secondViewController and then remove it once the delegate method is called.

Well as you said you already have this - (void)webViewDidFinishLoad:(UIWebView *)wva in your sub-class ViewJeuSolo. So why do not you just set BOOL variable inside this method. And when loading has been finsished then it will come to your this line [self.navigationController pushViewController:secondViewController animated:YES];. So before that only did you check like this ?

- (void)webViewDidFinishLoad:(UIWebView *)wva
{
self.isloaded=YES; //declare insatance variable as bool
}

-(IBAction) boutonJouer:(id)sender{

    //Do something

    ViewJeuSolo *secondViewController =
    [self.storyboard instantiateViewControllerWithIdentifier:@"ViewJeuSolo"];

//now check here you bool variable value
if (secondViewController.isloaded==YES)
{
    [self.navigationController pushViewController:secondViewController animated:YES];
secondViewController.isloaded=NO;
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top