Commit b849eb9c authored by lujunye's avatar lujunye

计算webView高度

parent 699e8138
...@@ -95,7 +95,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, UITabBarControllerDeleg ...@@ -95,7 +95,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, UITabBarControllerDeleg
tabBarController.viewControllers = [v1, v2, v3, v4, v5] tabBarController.viewControllers = [v1, v2, v3, v4, v5]
tabBarController.selectedIndex = 2 // tabBarController.selectedIndex = 2
......
...@@ -11,8 +11,9 @@ import WebKit ...@@ -11,8 +11,9 @@ import WebKit
@objc protocol AddGuiGeCellDelegate { @objc protocol AddGuiGeCellDelegate {
@objc optional func AddGuiGeCellClick(cell:AddGuiGeCell) @objc optional func AddGuiGeCellClick(cell:AddGuiGeCell)
@objc optional func AddGuiGeCellWebViewHeight(height:CGFloat)
} }
class AddGuiGeCell: UITableViewCell { class AddGuiGeCell: UITableViewCell ,WKNavigationDelegate{
var delegate:AddGuiGeCellDelegate? var delegate:AddGuiGeCellDelegate?
@IBOutlet weak var btmH: NSLayoutConstraint! @IBOutlet weak var btmH: NSLayoutConstraint!
@IBAction func btnClick(_ sender: Any) { @IBAction func btnClick(_ sender: Any) {
...@@ -28,7 +29,7 @@ class AddGuiGeCell: UITableViewCell { ...@@ -28,7 +29,7 @@ class AddGuiGeCell: UITableViewCell {
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
selectionStyle = .none selectionStyle = .none
webView.navigationDelegate = self
// Initialization code // Initialization code
} }
...@@ -37,5 +38,14 @@ class AddGuiGeCell: UITableViewCell { ...@@ -37,5 +38,14 @@ class AddGuiGeCell: UITableViewCell {
// Configure the view for the selected state // Configure the view for the selected state
} }
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webView.scrollView.isScrollEnabled = false
webView.evaluateJavaScript("document.body.scrollHeight") { (result, error) in
let h = result as! CGFloat
print("webH = ",h)
self.delegate?.AddGuiGeCellWebViewHeight?(height:h)
}
}
} }
...@@ -66,7 +66,7 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo ...@@ -66,7 +66,7 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
var yunShuTypeArr = ["冷链","常温","热链"] var yunShuTypeArr = ["冷链","常温","热链"]
var countryArr = ["中国"] var countryArr = ["中国"]
var layout = UICollectionViewFlowLayout() var layout = UICollectionViewFlowLayout()
var webH:CGFloat = 0
var glSelectView:GLAlertSelectView? var glSelectView:GLAlertSelectView?
var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录 var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录
...@@ -1490,7 +1490,7 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo ...@@ -1490,7 +1490,7 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
case 4:return 49 case 4:return 49
default: default:
if goodsDesc.count > 0 {//有内容 if goodsDesc.count > 0 {//有内容
return 250 return webH
}else{//无内容 }else{//无内容
if isAllEditing {//非编辑 if isAllEditing {//非编辑
return 0.001 return 0.001
...@@ -1777,7 +1777,12 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo ...@@ -1777,7 +1777,12 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
return dataChangeString(sender:data4) return dataChangeString(sender:data4)
} }
func AddGuiGeCellWebViewHeight(height: CGFloat) {
if webH == 0 {
webH = height
listTbv.reloadData()
}
}
var goodsDesc = "" var goodsDesc = ""
func getHTMLByVc(_ model: String!) { func getHTMLByVc(_ model: String!) {
......
...@@ -11,6 +11,7 @@ import LGButton ...@@ -11,6 +11,7 @@ import LGButton
import Photos import Photos
import IQKeyboardManagerSwift import IQKeyboardManagerSwift
import Dollar import Dollar
import WebKit
protocol ProductDetailViewControllerDelegate { protocol ProductDetailViewControllerDelegate {
func reloadDataByProductDetailViewController() func reloadDataByProductDetailViewController()
...@@ -58,7 +59,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -58,7 +59,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录 var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录
var isYuShouShangPin:Bool?//是否为预售商品 var isYuShouShangPin:Bool?//是否为预售商品
var webH:CGFloat = 0
var itemTypeArr:Array<Int>? = []//多选 var itemTypeArr:Array<Int>? = []//多选
var shangPinStatus:Int? = 0//商品状态 var shangPinStatus:Int? = 0//商品状态
var yunShuType:Int? = 0//运输类型 var yunShuType:Int? = 0//运输类型
...@@ -456,7 +457,9 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -456,7 +457,9 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
cell.delegate = self cell.delegate = self
cell.imgBtn.tag = indexPath.row cell.imgBtn.tag = indexPath.row
if goodsDesc.count > 0 { if goodsDesc.count > 0 {
cell.webView.isHidden = false cell.webView.isHidden = false
let headerString : String = "<header><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'><style>img{max-width:100%}</style></header>" let headerString : String = "<header><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'><style>img{max-width:100%}</style></header>"
let goodsDescHmtl = "<html>" + goodsDesc + "</html>" let goodsDescHmtl = "<html>" + goodsDesc + "</html>"
...@@ -1089,9 +1092,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -1089,9 +1092,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
case 4:return 49 case 4:return 49
default: default:
if goodsDesc.count > 0 { if goodsDesc.count > 0 {
return webH
return 450*glscale
} }
return 98 return 98
...@@ -1255,6 +1256,12 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -1255,6 +1256,12 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
} }
func AddGuiGeCellWebViewHeight(height: CGFloat) {
if webH == 0 {
webH = height
listTbv.reloadData()
}
}
//MARK:---商品详情回调的数据 //MARK:---商品详情回调的数据
var goodsDesc = "" var goodsDesc = ""
func getHTMLByVc(_ model: String!) { func getHTMLByVc(_ model: String!) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment