ios - How to wait until webViewDidFinishLoad is called? -


i'm creating ios app.

i separated pdf has multi page each pages,

and create uiwebviews show each pages.

the code this.

for( int = 0; < _pagenumbers; i++) {     _webview = [[uiwebview alloc]init];     _webview.delegate = self;     _webview.frame = imageviewframe;     _webview.scalespagetofit = yes;     _webview.autoresizingmask =     uiviewautoresizingflexibleleftmargin  |     uiviewautoresizingflexiblewidth       |     uiviewautoresizingflexiblerightmargin |     uiviewautoresizingflexibletopmargin   |     uiviewautoresizingflexibleheight      |     uiviewautoresizingflexiblebottommargin;     [self setimageatindex:i toscrollview:imagescrollview]; }  - (void)setimageatindex:(nsinteger)index toscrollview:(imagescrollview*)scrollview {     uiwebview   *thewebview = (scrollview.subviews)[0];     if (index < 0 || [webviews count] <= index) {         thewebview = nil;         return;     }      dispatch_queue_t queueloadpdf = dispatch_get_global_queue(dispatch_queue_priority_default, 0);     dispatch_sync(queueloadpdf, ^{         nsstring    *document = [[[[nsstring alloc]initwithstring:_documwntpath]stringbyappendingstring:@"/"]stringbyappendingformat:@"page%zd.pdf",(index + 1) ];          nsurl   *url = [nsurl fileurlwithpath:document];         nsstring *urlstring = [url absolutestring];         nsstring *encodedstring=[urlstring stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];         nsurl *weburl = [nsurl urlwithstring:encodedstring];         nsurlrequest    *req = [nsurlrequest requestwithurl:weburl];         [thewebview loadrequest:req];     }); } 

the pdf pages big. after calling loadrequest, program go loop , creates new uiwebview.

i want wait until webviewdidfinishload called before returning loop.

is there solutions?

thank helps.

@masarukitajima it's kinda hard see trying do. initial thoughts same @chinttu -maddy- ramani's when looked @ code again, see more problem rough assumptions. throw couple of questions , should think design again answer.

somehow code doesn't make sense me. see [webviews count] in code. have multiple webviews in scroll view? see _webview think it's member variable , initiating in for-loop? do?? should able answer first. loading 1 webview not because didn't know how load next webview in webviewdidfinishload because have 1 webview??

second, think want load 1 webview @ time , design doesn't make sense me either. should load next webview when imagescrollview scrolled down next webview. idea pretty same how load next data in table view when last cell displayed.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -