Commit b849eb9c authored by lujunye's avatar lujunye

计算webView高度

parent 699e8138
......@@ -95,7 +95,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, UITabBarControllerDeleg
tabBarController.viewControllers = [v1, v2, v3, v4, v5]
tabBarController.selectedIndex = 2
// tabBarController.selectedIndex = 2
......
......@@ -11,8 +11,9 @@ import WebKit
@objc protocol AddGuiGeCellDelegate {
@objc optional func AddGuiGeCellClick(cell:AddGuiGeCell)
@objc optional func AddGuiGeCellWebViewHeight(height:CGFloat)
}
class AddGuiGeCell: UITableViewCell {
class AddGuiGeCell: UITableViewCell ,WKNavigationDelegate{
var delegate:AddGuiGeCellDelegate?
@IBOutlet weak var btmH: NSLayoutConstraint!
@IBAction func btnClick(_ sender: Any) {
......@@ -28,7 +29,7 @@ class AddGuiGeCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
selectionStyle = .none
webView.navigationDelegate = self
// Initialization code
}
......@@ -37,5 +38,14 @@ class AddGuiGeCell: UITableViewCell {
// 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
var yunShuTypeArr = ["冷链","常温","热链"]
var countryArr = ["中国"]
var layout = UICollectionViewFlowLayout()
var webH:CGFloat = 0
var glSelectView:GLAlertSelectView?
var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录
......@@ -1490,7 +1490,7 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
case 4:return 49
default:
if goodsDesc.count > 0 {//有内容
return 250
return webH
}else{//无内容
if isAllEditing {//非编辑
return 0.001
......@@ -1777,7 +1777,12 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
return dataChangeString(sender:data4)
}
func AddGuiGeCellWebViewHeight(height: CGFloat) {
if webH == 0 {
webH = height
listTbv.reloadData()
}
}
var goodsDesc = ""
func getHTMLByVc(_ model: String!) {
......
......@@ -11,6 +11,7 @@ import LGButton
import Photos
import IQKeyboardManagerSwift
import Dollar
import WebKit
protocol ProductDetailViewControllerDelegate {
func reloadDataByProductDetailViewController()
......@@ -58,7 +59,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录
var isYuShouShangPin:Bool?//是否为预售商品
var webH:CGFloat = 0
var itemTypeArr:Array<Int>? = []//多选
var shangPinStatus:Int? = 0//商品状态
var yunShuType:Int? = 0//运输类型
......@@ -456,7 +457,9 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
cell.delegate = self
cell.imgBtn.tag = indexPath.row
if goodsDesc.count > 0 {
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 goodsDescHmtl = "<html>" + goodsDesc + "</html>"
......@@ -1089,9 +1092,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
case 4:return 49
default:
if goodsDesc.count > 0 {
return 450*glscale
return webH
}
return 98
......@@ -1255,6 +1256,12 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
}
func AddGuiGeCellWebViewHeight(height: CGFloat) {
if webH == 0 {
webH = height
listTbv.reloadData()
}
}
//MARK:---商品详情回调的数据
var goodsDesc = ""
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