Change example rows dimension to be more appropriate
Seto Elkahfi committed
Apr 8, 2017 at 17:38 UTC
f181bf09a1a6bfad654b824e3314e9cc34d18c4d
4 files changed
+42
-25
Example/JomloTableView/Base.lproj/Main.storyboard
+1
-1
@@ -18,7 +18,7 @@
18
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
19
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
20
</tableView>
21
- <navigationItem key="navigationItem" title="JomloTableView" id="82t-X7-det">
21
+ <navigationItem key="navigationItem" title="JomloTableView Example" id="82t-X7-det">
22
<barButtonItem key="backBarButtonItem" title="Back" id="EVO-cv-TLr"/>
23
</navigationItem>
24
<connections>
Example/JomloTableView/Rows/SimpleCell.swift
+11
-7
@@ -11,16 +11,19 @@ import JomloTableView
11
12
class SimpleCell: JomloTableViewCell {
13
14
- @IBOutlet var textlabel: UILabel!
14
+ @IBOutlet var titleLabel: UILabel!
15
+ @IBOutlet var subTitleLabel: UILabel!
16
17
}
18
19
class SimpleRow: JomloTableViewRow {
20
20
- var text: String!
21
+ var title: String!
22
+ var subTitle: String!
23
22
- init(_ text: String) {
23
- self.text = text
24
+ init(_ title: String, subTitle: String) {
25
+ self.title = title
26
+ self.subTitle = subTitle
27
}
28
29
@@ -29,16 +32,17 @@ class SimpleRow: JomloTableViewRow {
32
}
33
34
override var rowHeight: CGFloat {
32
- return 80
35
+ return UITableViewAutomaticDimension
36
}
37
38
override var estimatedRowHeight: CGFloat {
36
- return 80
39
+ return 64
40
}
41
42
override func populateView(cell: JomloTableViewCell) {
43
let cell = cell as! SimpleCell
41
- cell.textlabel.text = text
44
+ cell.titleLabel.text = title
45
+ cell.subTitleLabel.text = subTitle
46
}
47
48
}
Example/JomloTableView/Rows/SimpleCell.xib
+23
-10
@@ -6,33 +6,46 @@
6
<dependencies>
7
<deployment identifier="iOS"/>
8
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
9
+ <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
10
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11
</dependencies>
12
<objects>
13
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
13
- <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="SimpleCell" rowHeight="93" id="Jxp-d1-zT1" customClass="SimpleCell" customModule="JomloTableView_Example" customModuleProvider="target">
14
- <rect key="frame" x="0.0" y="0.0" width="584" height="93"/>
14
+ <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="SimpleCell" rowHeight="120" id="Jxp-d1-zT1" customClass="SimpleCell" customModule="JomloTableView_Example" customModuleProvider="target">
15
+ <rect key="frame" x="0.0" y="0.0" width="598" height="120"/>
16
<autoresizingMask key="autoresizingMask"/>
17
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Jxp-d1-zT1" id="150-Wq-GWr">
17
- <rect key="frame" x="0.0" y="0.0" width="584" height="92"/>
18
+ <rect key="frame" x="0.0" y="0.0" width="598" height="119.5"/>
19
<autoresizingMask key="autoresizingMask"/>
20
<subviews>
20
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SimpleRow" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fUm-db-ewC">
21
- <rect key="frame" x="244.5" y="36" width="96.5" height="21"/>
22
- <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
21
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fUm-db-ewC" userLabel="Title">
22
+ <rect key="frame" x="8" y="8" width="582" height="19.5"/>
23
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
24
<nil key="textColor"/>
25
<nil key="highlightedColor"/>
26
</label>
27
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="top" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Multi line explanation" textAlignment="justified" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c4C-y0-zNM" userLabel="Sub title">
28
+ <rect key="frame" x="8" y="27.5" width="582" height="84"/>
29
+ <fontDescription key="fontDescription" type="italicSystem" pointSize="14"/>
30
+ <color key="textColor" red="0.50196081400000003" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
31
+ <nil key="highlightedColor"/>
32
+ </label>
33
</subviews>
34
<constraints>
28
- <constraint firstItem="fUm-db-ewC" firstAttribute="centerY" secondItem="150-Wq-GWr" secondAttribute="centerY" id="1Ky-R2-nPS"/>
29
- <constraint firstItem="fUm-db-ewC" firstAttribute="centerX" secondItem="150-Wq-GWr" secondAttribute="centerX" id="WpU-N7-rLz"/>
35
+ <constraint firstAttribute="trailingMargin" secondItem="c4C-y0-zNM" secondAttribute="trailing" id="7H1-oo-vNa"/>
36
+ <constraint firstItem="fUm-db-ewC" firstAttribute="top" secondItem="150-Wq-GWr" secondAttribute="topMargin" id="BgU-P2-3aG"/>
37
+ <constraint firstItem="c4C-y0-zNM" firstAttribute="top" secondItem="fUm-db-ewC" secondAttribute="bottom" id="LV4-fK-spS"/>
38
+ <constraint firstItem="c4C-y0-zNM" firstAttribute="leading" secondItem="150-Wq-GWr" secondAttribute="leadingMargin" id="SAz-9d-pBI"/>
39
+ <constraint firstAttribute="trailingMargin" secondItem="fUm-db-ewC" secondAttribute="trailing" id="UAK-Ng-b4v"/>
40
+ <constraint firstItem="fUm-db-ewC" firstAttribute="leading" secondItem="150-Wq-GWr" secondAttribute="leadingMargin" id="bYJ-fp-AlM"/>
41
+ <constraint firstAttribute="bottomMargin" secondItem="c4C-y0-zNM" secondAttribute="bottom" id="sFa-ar-CZo"/>
42
</constraints>
43
</tableViewCellContentView>
44
<connections>
33
- <outlet property="textlabel" destination="fUm-db-ewC" id="uhd-rH-Xuq"/>
45
+ <outlet property="subTitleLabel" destination="c4C-y0-zNM" id="qBq-ng-9dC"/>
46
+ <outlet property="titleLabel" destination="fUm-db-ewC" id="Q28-MB-00v"/>
47
</connections>
35
- <point key="canvasLocation" x="138" y="83.5"/>
48
+ <point key="canvasLocation" x="145" y="97"/>
49
</tableViewCell>
50
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
51
</objects>
Example/JomloTableView/ViewController.swift
+7
-7
@@ -18,28 +18,28 @@ class ViewController: UIViewController {
18
override func viewDidLoad() {
19
super.viewDidLoad()
20
21
- let row0 = SimpleRow("Simple table view")
21
+ let row0 = SimpleRow("Simple table view", subTitle: "A simple table view like we usually use. But this time, we use JomloTableView.")
22
exampleSection.addRow(row: row0)
23
24
- let row1 = SimpleRow("Load more")
24
+ let row1 = SimpleRow("Load more", subTitle: "A JomloTableView with load more row at the bottom. Will load infinite row if we scroll the table view to the bottom.")
25
row1.setOnRowClicked { (row) in
26
self.performSegue(withIdentifier: "showLoadMoreExample", sender: self)
27
}
28
exampleSection.addRow(row: row1)
29
30
- let row2 = SimpleRow("Dynamic height")
30
+ let row2 = SimpleRow("Dynamic height", subTitle: "Example how to use dynamic height for single row. In fact, this example rows is also use dynamic height.")
31
exampleSection.addRow(row: row2)
32
33
- let row3 = SimpleRow("WebView")
33
+ let row3 = SimpleRow("WebView", subTitle: "A JomloTableView with WebView inside of its row.")
34
exampleSection.addRow(row: row3)
35
36
- let row4 = SimpleRow("Image list")
36
+ let row4 = SimpleRow("Image list", subTitle: "A JomloTableView with image views inside of its row.")
37
exampleSection.addRow(row: row4)
38
39
- let row5 = SimpleRow("Long scrollable layout")
39
+ let row5 = SimpleRow("Long scrollable layout", subTitle: "A JomloTableView which doesn't look like a table view. ")
40
exampleSection.addRow(row: row5)
41
42
- let row6 = SimpleRow("StackView row")
42
+ let row6 = SimpleRow("StackView row", subTitle: "A JomloTableView with UIStackView inside of its rows. Here we use UITableViewAutomaticDimension for row's height property.")
43
exampleSection.addRow(row: row6)
44
45
jomloTableView.addSection(section: exampleSection)