Hello,
I want to show expanded more information (content from a html file) when man clicks on a button.
when man clicks on the button again, the more information is hidden.
The more information is shown in a web view.
After the content of the web view is loaded, the height of web view is set. So that the more inforamtion is shown rightly.
Some of the code are:
NSLogI(@" path %@", path); // e.g.Path is "...Library/Developer/CoreSimulator/Devices/4074CF50-3416-4D41-8FF6-BD9D9A063512/data/Containers/Bundle/Application/293CCA8A-A184-4232-8E7E-55F4FF7E218F/***.app/help.html"
NSMutableURLRequest* req = [[NSMutableURLRequest alloc] init];
req.URL = [NSURL fileURLWithPath:path isDirectory: NO];
req.cachePolicy = NSURLRequestReloadIgnoringCacheData;
req.timeoutInterval = 1;
[self.webView loadRequest:req];
- (void)webViewDidFinishLoad:(UIWebView *)webView {
double webViewHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.height"] floatValue];
self.webViewHeight = webViewHeight;
self.btnShowHelp.hidden = NO;
}
If I use xcode 7.3.1 to run the code, it works well on devices and simulators on iOS which is less than iOS 10.
If I use Xcode 8 beta (8S128d) to run the same code, some content of the web view is cut off on iOS that is less than iOS 10,
if the content is a little bit longer. And No content is shown on devices and simulators on iOS 10, if I use Xcode 8 beta to run the code.
In the above method [[webView stringByEvaluatingJavaScriptFromString: @"document.height"] floatValue] is 0 on iOS 10 devices and simulators.
example content of help.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">/discussion/http:/ <p style=
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>xxxxx</title><link href="checklistStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="NativeBridge.js"></script>
<div id="content" class="checklist">
<p class="Headline1">xxxxxxxxxxxxxxxxxxxxx</p> <p class="Text3"><strong>Tipp:</strong> yyyyyyyyyyyyyyyyyyyy</p> <p class="Headline1">zzzzzzzzzzz</p>My Questions:
1. [[webView stringByEvaluatingJavaScriptFromString: @"document.height"] floatValue] in iOS 10 returns 0. No content is shown on iOS.
2. Using Xcode 8 beta 2 to run the code, the content of web view is cut off on iOS that is less than iOS 10, when the content is a little bit longer.
But the same content can be shown right on iOS that is less than iOS 10 when the code is run from code 7.3.1.
Are the above two bugs of iOS 10/ Xcode 8 beta 2?
3. With Xcode 8 oder iOS 10 how can I get the right height of web view?
I tried changing webViewDidFinishLoad:(UIWebView *)webView to the following:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
float height1 = [[webView stringByEvaluatingJavaScriptFromString:@"document.height"] floatValue];
float height2 = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];
float height3 = webView.scrollView.contentSize.height;
self.webViewHeight = MAX(height1, MAX(height2, height3));
self.btnShowHelp.hidden = NO;
}
In iOS 10, height1 is 0, height 2 and height 3 have a value. but they are the right height. The content of the web view
is cut off, if the content is a little bit longer, when the code is run from Xcode 8 beta 2.
Thanks a lot