During this time, there are a few ways to write about the content of the form that is uploaded from the backend, and then the feature that will be displayed again at the mobile end.
first of all, if the content is displayed directly, or the SizeToFit operation, then may cause the picture to exceed the screen size, the font becomes very small result, so here uses the UIWebView delegate method and adds the HTML the label language, The JavaScript action method is used. You can study the code as follows:
Web
-(UIWebView *) Detailwebview
{
if (_detailwebview = = nil) {
_detailwebview = [UIWebView new];
_detailwebview.delegate = self;
_detailwebview.scrollview.bounces = NO;
_detailwebview.scrollview.showshorizontalscrollindicator = NO;
_detailwebview.scrollview.scrollenabled = NO;
_detailwebview.datadetectortypes = Uidatadetectortypeall;
[_detailwebview SizeToFit];
}
return _detailwebview;
}
NSString *htmlcontent = [NSString stringwithformat:@
#pragma mark-----WebView delegate-(void) Webviewdidfinishload: (UIWebView *) WebView {//Get page height (pixel) nsstring *
CLIENTHEIGHT_STR = [WebView stringbyevaluatingjavascriptfromstring: @ "Document.body.offsetHeight"];
float clientheight = [Clientheight_str floatvalue];
Set to WebView on webview.frame = CGRectMake (_wherenewslabel.bottom+10, f_device_w-30, clientheight); The following write is to obtain more accurate content height, no need to do other calculations//get content actual height (pixel) nsstring * height_str= [WebView stringbyevaluatingjavascriptfroms Tring: @ "document.getElementById (' Webview_content_wrapper '). offsetheight + parseint (window.getComputedStyle ( document.getElementsByTagName (' body ') [0]). GetPropertyValue (' margin-top ')) + parseint (window.getComputedStyle (
document.getElementsByTagName (' body ') [0]). GetPropertyValue (' Margin-bottom ')];
float height = [height_str floatvalue];
Set WebView height Again (point) Webview.frame = CGRectMake (_wherenewslabel.bottom+10, f_device_w-30, height); if ([Self.delegaTe respondstoselector: @selector (backwebviewwithheight:)]) {[Self.delegate backwebviewwithheight:webview.bottom+5]
; }
}