Smi*_*ith 3 iphone objective-c uiwebview mathjax ios
我正在加载mathml内容UIWebView,有时数学表达式可能会跨越我的webview框架,用户必须滚动才能查看超出边界的内容.为了处理这种情况,只要用户是可滚动的内容,我就会向用户显示一个可视箭头指示器.我的问题是,在我webViewDidFinishLoad尝试访问时webview,scrollView.contentSize它并没有返回确切的内容大小,但是如果我在一些延迟之后用其他方法检查这是正确的内容大小.但是用计时器检查我认为不是一种有效的方法.下面是我的代码片段,
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"contentSize %@",NSStringFromCGSize(webView.scrollView.contentSize));// returning worng values, even if content size is more this is returning default frame values of webview
[self performSelector:@selector(checkContentSize) withObject:self afterDelay:1.5];//working properly after delay
}
Run Code Online (Sandbox Code Playgroud)
如何在webView不使用performSelector延迟后获得适当的内容大小?
我甚至尝试过这个帖子并尝试在两者中捕获该事件shouldStartLoadWithRequest,webViewDidFinishLoad但即使这样也没用.
试试这个
float height = [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollHeight;"] floatValue];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1287 次 |
| 最近记录: |