|
@@ -129,6 +129,8 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
|
|
|
|
|
|
}
|
|
}
|
|
}).disposed(by: disposeBag)
|
|
}).disposed(by: disposeBag)
|
|
|
|
+ webView.scrollView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.new, context: nil)
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
private lazy var titleLabel: UILabel = {
|
|
@@ -214,18 +216,8 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
|
|
return collectionView
|
|
return collectionView
|
|
}()
|
|
}()
|
|
|
|
|
|
-// private lazy var collectionViewLayout: UICollectionViewLeftAlignedLayout = {
|
|
|
|
-// let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
|
|
|
|
-// collectionViewLayout.minimumLineSpacing = 10
|
|
|
|
-// collectionViewLayout.minimumInteritemSpacing = 10
|
|
|
|
-// collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
|
|
|
|
-// collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 30)/4, height: 24)
|
|
|
|
-// collectionViewLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
|
|
|
-// return collectionViewLayout
|
|
|
|
-// }()
|
|
|
|
-
|
|
|
|
- private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
|
|
|
|
- let collectionViewLayout = UICollectionViewFlowLayout()
|
|
|
|
|
|
+ private lazy var collectionViewLayout: UICollectionViewLeftAlignedLayout = {
|
|
|
|
+ let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
|
|
collectionViewLayout.minimumLineSpacing = 10
|
|
collectionViewLayout.minimumLineSpacing = 10
|
|
collectionViewLayout.minimumInteritemSpacing = 10
|
|
collectionViewLayout.minimumInteritemSpacing = 10
|
|
collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
|
|
collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
|
|
@@ -234,6 +226,16 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
|
|
return collectionViewLayout
|
|
return collectionViewLayout
|
|
}()
|
|
}()
|
|
|
|
|
|
|
|
+// private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
|
|
|
|
+// let collectionViewLayout = UICollectionViewFlowLayout()
|
|
|
|
+// collectionViewLayout.minimumLineSpacing = 10
|
|
|
|
+// collectionViewLayout.minimumInteritemSpacing = 10
|
|
|
|
+// collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
|
|
|
|
+// collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 30)/4, height: 24)
|
|
|
|
+// collectionViewLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
|
|
|
+// return collectionViewLayout
|
|
|
|
+// }()
|
|
|
|
+
|
|
lazy var locationButton: UIButton = {
|
|
lazy var locationButton: UIButton = {
|
|
let locationButton = UIButton(type: UIButton.ButtonType.custom)
|
|
let locationButton = UIButton(type: UIButton.ButtonType.custom)
|
|
locationButton.setImage(kImage(name: "btn_address"), for: UIControl.State.normal)
|
|
locationButton.setImage(kImage(name: "btn_address"), for: UIControl.State.normal)
|
|
@@ -258,8 +260,8 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
|
|
//更新collectionView的高度约束
|
|
//更新collectionView的高度约束
|
|
let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
|
|
let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
|
|
collectionViewheight = contentSize.height
|
|
collectionViewheight = contentSize.height
|
|
- collectionView.snp.remakeConstraints { (make) in
|
|
|
|
- make.top.equalTo(webView.snp_bottom).offset(15)
|
|
|
|
|
|
+ collectionView.snp.remakeConstraints {[weak self] (make) in
|
|
|
|
+ make.top.equalTo((self?.webView.snp_bottom)!).offset(15)
|
|
make.left.equalTo(14)
|
|
make.left.equalTo(14)
|
|
make.right.equalTo(-14)
|
|
make.right.equalTo(-14)
|
|
make.height.equalTo(contentSize.height)
|
|
make.height.equalTo(contentSize.height)
|
|
@@ -312,8 +314,6 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
|
|
locationButton.setTitle(communityPostDetailModel?.location, for: UIControl.State.normal)
|
|
locationButton.setTitle(communityPostDetailModel?.location, for: UIControl.State.normal)
|
|
locationButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 3)
|
|
locationButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 3)
|
|
}
|
|
}
|
|
- webView.scrollView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.new, context: nil)
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -381,10 +381,14 @@ extension CommunityRecommendDetailHTMLTableViewCell: UICollectionViewDelegateFlo
|
|
|
|
|
|
extension CommunityRecommendDetailHTMLTableViewCell {
|
|
extension CommunityRecommendDetailHTMLTableViewCell {
|
|
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
|
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
|
- weak var weakself = self
|
|
|
|
if keyPath == "contentSize" {
|
|
if keyPath == "contentSize" {
|
|
- webViewCellHeight = weakself?.webView.scrollView.contentSize.height
|
|
|
|
- weakself?.tableView?.reloadData()
|
|
|
|
|
|
+ if communityPostDetailModel != nil {
|
|
|
|
+
|
|
|
|
+ if self.webView.scrollView.contentSize.height != webViewCellHeight {
|
|
|
|
+ self.tableView?.reloadData()
|
|
|
|
+ }
|
|
|
|
+ self.webViewCellHeight = self.webView.scrollView.contentSize.height
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|