Asish AP
Asish AP

Reputation: 4441

Background Loading a url in a uiwebview

Hi I'm a have an app in which i load webpage in a uiwebview .So each time it takes too much time for loading . So i need to load the webpage in a background mode. Any one know how to done this.

Any help would be appreciable.

Upvotes: 3

Views: 6659

Answers (2)

Rayfleck
Rayfleck

Reputation: 12106

- (void) start_Web_View {
     UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,460)];
     wv.delegate = self;
     [wv loadRequest:
          [NSURLRequest requestWithURL:
                    @"http://long_loading_web_site"]];
      // go do something else to amuse the user while the web site loads...
  }


 #pragma mark webview delegate
 - (void) webViewDidFinishLoad:(UIWebView *)webView {
     [self.view addSubview: webView];  // load is done, so add the webview to self.view so it's visible.
 }

Upvotes: 4

Javier Soto
Javier Soto

Reputation: 4870

Do you want to pre-load that other URL, so when it loads in the main webView it loads faster (or it's already loaded)?

You could create another UIWebView and don't show it at all, and make it load the other URL (you can set the frame of it outside the screen bounds).

Example:

UIWebView *dummyWebView = [[UIWebView alloc] init];
dummyWebView.frame = CGRectMake(-1, -1, 1, 1);

Upvotes: 0

Related Questions