I have a UIWebView And how can i get It's scroll position ?
I know, that UIWebView has a UIScroller subview. But I can't get offset of this UIScroller (((
There is a better and more resource-friendly way to do this:
UIWebView *webView;
CGFloat offset = webView.scrollView.contentOffset.y;
via http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html
This trick works for me.
UIWebView *webView;
int scrollPosition = [[webView stringByEvaluatingJavaScriptFromString:@"window.pageYOffset"] intValue];
Please refer to the answer given by zamber for a better solution on iOS 5 and later. My answer was for iOS 4 and below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With