How to disable UIWebView refreshing?

I have made an app that contains a lot of PDF files that are loaded in the UIWebView.

Whenever I open the PDF, close it, and then go back to it, the file starts from the top again, it reloads. I don't want it to reload once the user goes out of the file and comes back to it. Can someone help with the code for it to stop refreshing and where I should insert it?

The code I use is down below. Can someone tell me what's wrong with it, and what I should do so it doesn't refresh again?

#import "ViewController2.h"
#import <iAd/iAd.h>

@interface ViewController2 ()


@implementation ViewController2

- (void)viewDidLoad


    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a 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 to 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 to set webview.delegate = self;

Need Your Help

what do mean by "delegate" in iPhone application

iphone dictionary

I usually read a word 'delegate' in the apple document and their library book. What exactly meaning about this word? Any special meaning in iPhone?

How to stream a string from a WCF REST service

c# wcf rest stream streaming

I wrote a very basic WCF REST Service in C#, that has the following in the service interface: