最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
怎么展示html格式的商品詳情-創(chuàng)新互聯(lián)

這篇文章主要介紹了怎么展示html格式的商品詳情的相關(guān)知識,內(nèi)容詳細(xì)易懂,操作簡單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇怎么展示html格式的商品詳情文章都會(huì)有所收獲,下面我們一起來看看吧。

清江浦網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,清江浦網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為清江浦千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個(gè)售后服務(wù)好的清江浦做網(wǎng)站的公司定做!

1、創(chuàng)建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、獲取服務(wù)端返回的html的字符串

NSString *description = minstr([storeInfo valueForKey:@“description"]);
//我這里更改一下html的格式,讓其符合手機(jī)端展示,如果服務(wù)端返回的就是手機(jī)端展示的樣式,這就可以不用更改 直接用就可以了
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、在WKWebView加載完成的代理方法中更改webView的frame

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
[webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
//更改webview的frame
_webView.frame = CGRectMake(0, _goodListView.bottom, _window_width, [result doubleValue]);//將WKWebView的高度設(shè)置為內(nèi)容高度
//更改背景scrollview的滑動(dòng)范圍
 _backScrollView.contentSize = CGSizeMake(0, _webView.bottom);
}];
    
//    插入js代碼,對圖片進(jìn)行點(diǎn)擊操作
[webView evaluateJavaScript:@"function assignImageClickAction(){var imgs=document.getElementsByTagName('img');var length=imgs.length;for(var i=0; i < length;i++){img=imgs[i];if(\"ad\" ==img.getAttribute(\"flag\")){var parent = this.parentNode;if(parent.nodeName.toLowerCase() != \"a\")return;}img.onclick=function(){window.location.href='image-preview:'+this.src}}}" completionHandler:^(id object, NSError *error) {
        
}];
[webView evaluateJavaScript:@"assignImageClickAction();" completionHandler:^(id object, NSError *error) {
        
}];
imageArray = [self getImgs:description];
 
 
}
#pragma mark -- 獲取文章中的圖片個(gè)數(shù)
- (NSMutableArray *)getImgs:(NSString *)string
{
   
NSMutableArray *arrImgURL = [[NSMutableArray alloc] init];
NSArray *array = [string componentsSeparatedByString:@"

4、在WKWebView的代理方法中攔截圖片添加的點(diǎn)擊方法,可使用HZPhotoBrowser來展示圖片

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{
    
 NSURLRequest *request = navigationAction.request;
if ([request.URL.scheme isEqualToString: @"image-preview"])
 {
        
NSString *url = [request.URL.absoluteString substringFromIndex:14];
        
        
 //啟動(dòng)圖片瀏覽器, 跳轉(zhuǎn)到圖片瀏覽頁面
if (imageArray.count != 0) {
            
HZPhotoBrowser *browserVc = [[HZPhotoBrowser alloc] init];
browserVc.imageArray = imageArray;
browserVc.imageCount = imageArray.count; // 圖片總數(shù)
browserVc.currentImageIndex = (int)[imageArray indexOfObject:url];//當(dāng)前點(diǎn)擊的圖片
[browserVc show];
            
}
decisionHandler(WKNavigationActionPolicyAllow);
return;
        
}
 
decisionHandler(WKNavigationActionPolicyAllow);
NSLog(@"在發(fā)送請求之前:%@",navigationAction.request.URL.absoluteString);

關(guān)于“怎么展示html格式的商品詳情”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“怎么展示html格式的商品詳情”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道。


當(dāng)前名稱:怎么展示html格式的商品詳情-創(chuàng)新互聯(lián)
鏈接URL:http://fisionsoft.com.cn/article/dsecee.html