I have the following UIWebView
implementation and I want to set the scroll after the webview is loaded. However, scroll programmatically has no effect on UIWebView
.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSString *urlAddress = @"http://www.xxxx.com/private-dining";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[privateDiningWebView loadRequest:requestObj];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
privateDiningWebView.scrollView.contentOffset = CGPointMake(0, 300);
});
}
You can set delegate for UIWebview and try this code :
- (void)webViewDidFinishLoad:(UIWebView *)webView {
privateDiningWebView.scrollView.contentOffset = CGPointMake(0, 300);
}