Commit b6eab630 authored by lujunye's avatar lujunye

消息中心自适应高度

parent e58a4566
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2020.04.26 12:26:42" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2eA-AH-8xd"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2020.04.26 12:26:42" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2eA-AH-8xd">
<rect key="frame" x="220" y="18.5" width="110" height="11"/> <rect key="frame" x="220" y="18.5" width="110" height="11"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="110" id="e4R-JE-YiJ"/>
<constraint firstAttribute="height" constant="11" id="nxW-7d-8Z8"/> <constraint firstAttribute="height" constant="11" id="nxW-7d-8Z8"/>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/> <fontDescription key="fontDescription" type="system" pointSize="11"/>
...@@ -34,11 +35,7 @@ ...@@ -34,11 +35,7 @@
</userDefinedRuntimeAttributes> </userDefinedRuntimeAttributes>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="系统信息" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uyq-HU-Mhn"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="系统信息" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uyq-HU-Mhn">
<rect key="frame" x="15" y="15" width="54" height="15"/> <rect key="frame" x="15" y="15" width="190" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="54" id="BSU-ua-bCn"/>
<constraint firstAttribute="height" constant="15" id="dcS-Od-pMI"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/> <fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" name="标题字颜色"/> <color key="textColor" name="标题字颜色"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
...@@ -46,8 +43,8 @@ ...@@ -46,8 +43,8 @@
<userDefinedRuntimeAttribute type="boolean" keyPath="isSkeletonable" value="YES"/> <userDefinedRuntimeAttribute type="boolean" keyPath="isSkeletonable" value="YES"/>
</userDefinedRuntimeAttributes> </userDefinedRuntimeAttributes>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L0Y-lD-jK8"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L0Y-lD-jK8">
<rect key="frame" x="15" y="45" width="315" height="45"/> <rect key="frame" x="15" y="55.5" width="315" height="34.5"/>
<attributedString key="attributedText"> <attributedString key="attributedText">
<fragment content="亲爱的格利食品网商户您好,您提交的(六和川香鸡柳 2.5kg*2)商品已通过审核。"> <fragment content="亲爱的格利食品网商户您好,您提交的(六和川香鸡柳 2.5kg*2)商品已通过审核。">
<attributes> <attributes>
...@@ -65,13 +62,14 @@ ...@@ -65,13 +62,14 @@
</subviews> </subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints> <constraints>
<constraint firstItem="L0Y-lD-jK8" firstAttribute="top" secondItem="Uyq-HU-Mhn" secondAttribute="bottom" constant="15" id="2Zg-5d-OiV"/> <constraint firstItem="2eA-AH-8xd" firstAttribute="leading" secondItem="Uyq-HU-Mhn" secondAttribute="trailing" constant="15" id="64g-49-VTK"/>
<constraint firstAttribute="trailing" secondItem="L0Y-lD-jK8" secondAttribute="trailing" constant="15" id="Es3-UB-hpq"/> <constraint firstAttribute="trailing" secondItem="L0Y-lD-jK8" secondAttribute="trailing" constant="15" id="Es3-UB-hpq"/>
<constraint firstItem="Uyq-HU-Mhn" firstAttribute="leading" secondItem="uwl-m3-ngX" secondAttribute="leading" constant="15" id="Hwa-1L-6Th"/> <constraint firstItem="Uyq-HU-Mhn" firstAttribute="top" secondItem="uwl-m3-ngX" secondAttribute="top" constant="15" id="Scu-8r-GhY"/>
<constraint firstAttribute="bottom" secondItem="L0Y-lD-jK8" secondAttribute="bottom" constant="15" id="TVQ-NZ-3Kp"/> <constraint firstAttribute="bottom" secondItem="L0Y-lD-jK8" secondAttribute="bottom" constant="15" id="TVQ-NZ-3Kp"/>
<constraint firstItem="L0Y-lD-jK8" firstAttribute="top" secondItem="Uyq-HU-Mhn" secondAttribute="bottom" constant="24.5" id="Yb3-lL-TpS"/>
<constraint firstItem="Uyq-HU-Mhn" firstAttribute="leading" secondItem="uwl-m3-ngX" secondAttribute="leading" constant="15" id="bIr-PI-RQM"/>
<constraint firstItem="2eA-AH-8xd" firstAttribute="top" secondItem="uwl-m3-ngX" secondAttribute="top" constant="18.5" id="bXx-va-TXG"/> <constraint firstItem="2eA-AH-8xd" firstAttribute="top" secondItem="uwl-m3-ngX" secondAttribute="top" constant="18.5" id="bXx-va-TXG"/>
<constraint firstAttribute="trailing" secondItem="2eA-AH-8xd" secondAttribute="trailing" constant="15" id="elW-DD-S3i"/> <constraint firstAttribute="trailing" secondItem="2eA-AH-8xd" secondAttribute="trailing" constant="15" id="elW-DD-S3i"/>
<constraint firstItem="Uyq-HU-Mhn" firstAttribute="top" secondItem="uwl-m3-ngX" secondAttribute="top" constant="15" id="erb-jN-Eas"/>
<constraint firstItem="L0Y-lD-jK8" firstAttribute="leading" secondItem="uwl-m3-ngX" secondAttribute="leading" constant="15" id="x8l-w3-84L"/> <constraint firstItem="L0Y-lD-jK8" firstAttribute="leading" secondItem="uwl-m3-ngX" secondAttribute="leading" constant="15" id="x8l-w3-84L"/>
</constraints> </constraints>
<userDefinedRuntimeAttributes> <userDefinedRuntimeAttributes>
......
...@@ -34,6 +34,9 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -34,6 +34,9 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie
make.left.right.bottom.equalTo(0) make.left.right.bottom.equalTo(0)
}) })
msgTbv?.estimatedRowHeight = 30
msgTbv!.rowHeight = UITableView.automaticDimension
msgTbv?.register(UINib(nibName: "MsgCenterCell", bundle: nil), forCellReuseIdentifier: "MsgCenterCell") msgTbv?.register(UINib(nibName: "MsgCenterCell", bundle: nil), forCellReuseIdentifier: "MsgCenterCell")
//下拉刷新相关设置 //下拉刷新相关设置
headerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadData)) headerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadData))
...@@ -42,9 +45,11 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -42,9 +45,11 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData)) footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
self.msgTbv!.mj_footer = footerMJ self.msgTbv!.mj_footer = footerMJ
self.msgTbv?.mj_header?.beginRefreshing() self.msgTbv?.mj_header?.beginRefreshing()
} }
var dataModelArr:Array<MessageListDataModel> = [] var dataModelArr:Array<MessageListDataModel> = []
var page = 1 var page = 1
//加载数据 //加载数据
@objc func loadData(){ @objc func loadData(){
page = 1 page = 1
...@@ -93,14 +98,18 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -93,14 +98,18 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie
} }
}) { (error) in }) { (error) in
self.msgTbv?.mj_footer?.endRefreshing() self.msgTbv?.mj_footer?.endRefreshing()
} }
} }
//MARK: -Cell delegate方法 //MARK: -Cell delegate方法
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 120 // func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// return 120
// }
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
print(tableView.estimatedRowHeight)
return 250
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.dataModelArr.count return self.dataModelArr.count
......
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