In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to display the product details of html format related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this article on how to display the product details of html format, let's take a look at it.
1. Create a WKWebview
-(WKWebView *) webView {if (! _ webView) {_ webView = [[WKWebView alloc] initWithFrame:CGRectMake (0,0, _ window_width, _ backScrollView.height)]; _ webView.navigationDelegate = self;_webView.opaque = NO;_webView.multipleTouchEnabled = YES;_webView.scrollView.delegate = self;_webView.scrollView.bounces = NO;_webView.scrollView.showsVerticalScrollIndicator = NO;_webView.scrollView.scrollEnabled = NO;_webView.scrollView.panGestureRecognizer.enabled = NO;} return _ webView;}
2. Get the string of html returned by the server
NSString * description = minstr ([storeInfo valueForKey:@ "description"]); / / I will change the format of html to conform to the mobile display. If the server returns the style displayed on the mobile, you can use it directly without changing it. NSString * htmlStyle = @ "* {min-width: 0! important;max-width: 100! important;} table {width: 100! important;} img {height: auto! important;}" Description = [htmlStyle stringByAppendingString:description]; NSString * aaa = @ ""; description = [aaa stringByAppendingString:description]; [_ webView loadHTMLString:description baseURL:nil]
3. Change the frame of webView in the proxy method after WKWebView loading
-(void) webView: (WKWebView *) webView didFinishNavigation: (null_unspecified WKNavigation *) navigation {[webView evaluate_JavaScript:@ "document.body.scrollHeight" completionHandler: ^ (id _ Nullable result, NSError * _ Nullable error) {/ / change the frame_webView.frame of webview = CGRectMake (0, _ goodListView.bottom, _ window_width, [result doubleValue]) / / set the height of WKWebView to content height / / change the sliding range of background scrollview _ backScrollView.contentSize = CGSizeMake (0, _ webView.bottom);}]; / / insert js code to click on the image [webView evaluate_JavaScript:@ "function assignImageClickAction () {var imgs=document.getElementsByTagName ('img'); var length=imgs.length;for (var iTun0; I < length;i++) {img=imgs [I] If (\ "ad\" = = img.getAttribute (\ "flag\")) {var parent = img.onclick=function [XSS _ clean]; if (parent.nodeName.toLowerCase ()! =\ "a\") return;} img.onclick=function () {_ window.location.href='image-preview:'+this.src}} "completionHandler: ^ (id object, NSError * error) {}]; [webView evaluate_JavaScript:@" assignImageClickAction (); "completionHandler: ^ (id object, NSError * error) {}] ImageArray = [self getImgs:description];} # pragma mark-get the number of pictures in the article-(NSMutableArray *) getImgs: (NSString *) string {NSMutableArray * arrImgURL = [[NSMutableArray alloc] init]; NSArray * array = [string componentsSeparatedByString:@ "
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.