ios - How to disable UIWebView refreshing? -


i have made app contains lot of pdf files loaded in uiwebview.

whenever open pdf, close it, , go it, file starts top again, reloads. don't want reload once user goes out of file , comes it. can code stop refreshing , should insert it?

the code use down below. can tell me what's wrong it, , should doesn't refresh again?

#import "viewcontroller2.h" #import <iad/iad.h>  @interface viewcontroller2 ()  @end  @implementation viewcontroller2    - (void)viewdidload      {       [super viewdidload];     // additional setup after loading view, typically nib.          nsstring *path = [[nsbundle mainbundle] pathforresource:@"hnonc" oftype:@"pdf"];         nsurl *url = [nsurl fileurlwithpath:path];         nsurlrequest *request = [nsurlrequest requestwithurl:url];         [webview loadrequest:request];         [webview setscalespagetofit:yes]; } 

you can save vertical offset of scrollview before close it:

 int pageyoffset = [[webview stringbyevaluatingjavascriptfromstring:@"window.pageyoffset"] intvalue]; [[nsuserdefaults standarduserdefaults] setinteger:pageyoffset forkey:@"yoffset"]; 

and when webview did load scroll saved offset

 - (void)webviewdidfinishload:(uiwebview *)wv {  int pageyoffset = [[nsuserdefaults standarduserdefaults] integerforkey:@"yoffset"]; [webview stringbyevaluatingjavascriptfromstring:[nsstring stringwithformat: @"window.scrollto(0, %d);",pageyoffset]]; }  

and don't forget set webview.delegate = self;


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -