|
1
|
# JomloTableView |
|
2
|
|
|
3
|
[](http://cocoapods.org/pods/JomloTableView) |
|
4
|
[](http://cocoapods.org/pods/JomloTableView) |
|
5
|
[](http://cocoapods.org/pods/JomloTableView) |
|
6
|
|
|
7
|
## Example |
|
8
|
|
|
9
|
To run the example project, clone the repo, and run `pod install` from the Example directory first. |
|
10
|
|
|
11
|
## Requirements |
|
12
|
|
|
13
|
iOS 8 |
|
14
|
|
|
15
|
## Installation |
|
16
|
|
|
17
|
JomloTableView is available through [CocoaPods](http://cocoapods.org). To install |
|
18
|
it, simply add the following line to your Podfile: |
|
19
|
|
|
20
|
```ruby |
|
21
|
pod "JomloTableView" |
|
22
|
``` |
|
23
|
|
|
24
|
## Usage |
|
25
|
|
|
26
|
Use single section with multiple rows. All the rows below are from single class. |
|
27
|
```swift |
|
28
|
import UIKit |
|
29
|
import JomloTableView |
|
30
|
|
|
31
|
// Another code |
|
32
|
|
|
33
|
@IBOutlet var jomloTableView: JomloTableView! |
|
34
|
|
|
35
|
var exampleSection = JomloTableViewSection() |
|
36
|
|
|
37
|
override func viewDidLoad() { |
|
38
|
super.viewDidLoad() |
|
39
|
|
|
40
|
let row0 = SimpleRow("Simple table view", subTitle: "A simple table view like we usually use. But this time, we use JomloTableView.") |
|
41
|
exampleSection.addRow(row: row0) |
|
42
|
|
|
43
|
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.") |
|
44
|
row1.setOnRowClicked { (row) in |
|
45
|
self.performSegue(withIdentifier: "showLoadMoreExample", sender: self) |
|
46
|
} |
|
47
|
exampleSection.addRow(row: row1) |
|
48
|
|
|
49
|
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.") |
|
50
|
exampleSection.addRow(row: row2) |
|
51
|
|
|
52
|
let row3 = SimpleRow("WebView", subTitle: "A JomloTableView with WebView inside of its row.") |
|
53
|
exampleSection.addRow(row: row3) |
|
54
|
|
|
55
|
let row4 = SimpleRow("Image list", subTitle: "A JomloTableView with image views inside of its row.") |
|
56
|
exampleSection.addRow(row: row4) |
|
57
|
|
|
58
|
let row5 = SimpleRow("Long scrollable layout", subTitle: "A JomloTableView which doesn't look like a table view. ") |
|
59
|
exampleSection.addRow(row: row5) |
|
60
|
|
|
61
|
let row6 = SimpleRow("StackView row", subTitle: "A JomloTableView with UIStackView inside of its rows. Here we use UITableViewAutomaticDimension for row's height property.") |
|
62
|
exampleSection.addRow(row: row6) |
|
63
|
|
|
64
|
jomloTableView.addSection(section: exampleSection) |
|
65
|
jomloTableView.reloadData() |
|
66
|
|
|
67
|
} |
|
68
|
|
|
69
|
// Another code |
|
70
|
``` |
|
71
|
 |
|
72
|
 |
|
73
|
|
|
74
|
This table view will load more row if loadMoreRow is populated. This example will load infinite rows if user scroll to bottom of table view. Eight rows per each load. |
|
75
|
```swift |
|
76
|
import UIKit |
|
77
|
import JomloTableView |
|
78
|
|
|
79
|
// Another code |
|
80
|
|
|
81
|
@IBOutlet var jomloTableView: JomloTableView! |
|
82
|
|
|
83
|
let tableSection = JomloTableViewSection() |
|
84
|
|
|
85
|
override func viewDidLoad() { |
|
86
|
super.viewDidLoad() |
|
87
|
|
|
88
|
jomloTableView.addSection(section: tableSection) |
|
89
|
addRows() |
|
90
|
} |
|
91
|
|
|
92
|
func addRows() { |
|
93
|
for _ in 0..<8 { |
|
94
|
let rowNumber = tableSection.count + 1 |
|
95
|
let row = SimpleRow("Row \(rowNumber)", subTitle: "Example row.") |
|
96
|
tableSection.addRow(row: row) |
|
97
|
} |
|
98
|
|
|
99
|
addLoadMoreRow() |
|
100
|
} |
|
101
|
|
|
102
|
func addLoadMoreRow() { |
|
103
|
|
|
104
|
let loadMoreRow = LoadMoreRow { |
|
105
|
// To get the effect or loading, delay the execution after 3 seconds |
|
106
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3, execute: { |
|
107
|
self.tableSection.removeLastRow() |
|
108
|
self.addRows() |
|
109
|
}) |
|
110
|
} |
|
111
|
|
|
112
|
tableSection.addRow(row: loadMoreRow) |
|
113
|
jomloTableView.reloadData() |
|
114
|
} |
|
115
|
|
|
116
|
// Another code |
|
117
|
|
|
118
|
``` |
|
119
|
 |
|
120
|
 |
|
121
|
 |
|
122
|
|
|
123
|
## Author |
|
124
|
|
|
125
|
Seto Elkahfi, setoelkahfi@gmail.com |
|
126
|
|
|
127
|
## License |
|
128
|
|
|
129
|
JomloTableView is available under the MIT license. See the LICENSE file for more info. |