Reputation: 86
Does anyone know if this solution can be approved by Apple submission app?
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
CGFloat webViewHeight = 0.0f;
if (self.subviews.count > 0) {
UIView *scrollerView = [self.subviews objectAtIndex:0];
if (scrollerView.subviews.count > 0) {
UIView *webDocView = scrollerView.subviews.lastObject;
if ([webDocView isKindOfClass:[NSClassFromString(@"UIWebDocumentView") class]])
webViewHeight = webDocView.frame.size.height;
}
}
}
Thanks. Hami.
Upvotes: 0
Views: 3228
Reputation: 16317
Implement the UIWebViewDidfinishLoad delegate method and use the following code
Hi ,
You can use the following methods to solve your problem.
For getting the pageOffset:
int pageYOffset = [[webViewObj stringByEvaluatingJavaScriptFromString:@"window.pageYOffset"] intValue];
For getting the total scroll height of a webpage:
int scrollHeight = [[webViewObj stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollHeight"] intValue];
For scrolling the webpage to a particular offset:
[webViewObj stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.body.scrollTop = %d",scrollHeight ]];
Upvotes: 7
Reputation: 299265
Rather than messing around with private classes that may change and break your app, why not use -stringByEvaluatingJavaScriptFromString:
to resize the web page with javascript?
Upvotes: 0