You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-1Lines changed: 55 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ You can think of it as `UITableView` but with several differences:
18
18
-**Powered by AutoLayout since the beginning**; it uses a combination of UIScrollView + UIStackView to offer an animation friendly controller ideal for fixed and dynamic row sizing.
19
19
-**You don't need to struggle yourself with view recycling**: suppose you have a layout composed by several different screens. There is no need of view recycling but it cause a more difficult managment of the layout. With a simpler and safer APIs set `ScrollStackView` is the ideal way to implement such layouts.
20
20
21
+
<aname="index"/>
22
+
21
23
## Table of Contents
22
24
23
25
-[Main Features](#mainfeatures)
@@ -37,9 +39,10 @@ You can think of it as `UITableView` but with several differences:
37
39
- [Rows Separator](#rowsseparator)
38
40
- [Tap On Rows](#taponrows)
39
41
-[Installation](#installation)
40
-
-A[uthor & License](#authorlicense)
42
+
-[Author & License](#authorlicense)
41
43
42
44
<aname="mainfeatures"/>
45
+
43
46
### Main Features
44
47
45
48
@@ -54,13 +57,17 @@ You can think of it as `UITableView` but with several differences:
### When to use `ScrollStackController` and when not
65
72
66
73
##### Yes
@@ -79,7 +86,10 @@ If you have a long list of rows you may experience delays.
79
86
80
87
So, `ScrollStackController` is generally not appropriate for screens that contain many views of the same type, all showing similar data (in these cases you should use `UITableView` or `UICollectionView`).
81
88
89
+
[↑ Back To Top](#index)
90
+
82
91
<aname="howtouseit"/>
92
+
83
93
### How to use it
84
94
85
95
The main class of the package is `ScrollStack`, a subclass of `UIScrollView`. It manages the layout of each row, animations and keep a strong reference to your rows.
@@ -128,7 +138,10 @@ let lastRow = scrollStack.lastRow
128
138
129
139
Let's take a look below.
130
140
141
+
[↑ Back To Top](#index)
142
+
131
143
<aname="addingrows"/>
144
+
132
145
#### Adding Rows
133
146
134
147
`ScrollStack` provides a comprehensive set of methods for managing rows, including inserting rows at the beginning and end, inserting rows above or below other rows.
@@ -157,7 +170,10 @@ The following code add a rows with the view of each view controller passed:
157
170
158
171
As you noticed there is not need to keep a strong reference to any view controller; they are automatically strong referenced by each row created to add them into the stack.
159
172
173
+
[↑ Back To Top](#index)
174
+
160
175
<aname="removingreplacingrows"/>
176
+
161
177
#### Removing / Replacing Rows
162
178
163
179
A similar set of APIs are used to remove existing rows from the stack:
Keep in mind: when you hide a rows the row still part of the stack and it's not removed, just hidden! If you get the list of rows by calling `rows` property of the `ScrollStack` you still see it.
208
230
231
+
[↑ Back To Top](#index)
232
+
209
233
<aname="reloadrows"/>
234
+
210
235
#### Reload Rows
211
236
212
237
Reload rows method allows you to refresh the layout of the entire stack (using `layoutIfNeeded()`) while you have a chance to update a specific row's `contentView` (aka the view of the managed `UIViewController`).
@@ -243,7 +268,10 @@ class GalleryVC: UIViewController, ScrollStackContainableController {
243
268
}
244
269
```
245
270
271
+
[↑ Back To Top](#index)
272
+
246
273
<aname="sizingrows"/>
274
+
247
275
#### Sizing Rows
248
276
249
277
You can control the size of your `UIViewController` inside a row of a `ScrollStack` in two ways:
@@ -260,7 +288,10 @@ Each of the following cases is covered inside the demo application:
260
288
- Growing row based on `UITextView`'s content in [NotesVC](https://github.com/malcommac/ScrollStackController/blob/master/ScrollStackControllerDemo/Child%20View%20Controllers/NotesVC.swift)
261
289
- Growing row based on `UITableView`'s content in [PricingVC](https://github.com/malcommac/ScrollStackController/blob/master/ScrollStackControllerDemo/Child%20View%20Controllers/PricingVC.swift)
262
290
291
+
[↑ Back To Top](#index)
292
+
263
293
<aname="fixedrowsize"/>
294
+
264
295
#### Fixed Row Size
265
296
266
297
If your view controller has a fixed size you can just return it as follows:
@@ -285,7 +316,10 @@ class GalleryVC: UIViewController, ScrollStackContainableController {
285
316
If your stack support single axis you can obivously avoid switch condition.
286
317
When you will add this view controller in a scroll stack it will be sized as you requested (any height/width constraint already in place will be removed).
287
318
319
+
[↑ Back To Top](#index)
320
+
288
321
<aname="fittinglayoutrowsize"/>
322
+
289
323
#### Fitting Layout Row Size
290
324
291
325
Sometimes you may want to have the content view sized by fitting the contents of the view controller's view. In these cases you can use `. fitLayoutForAxis`.
#### Working with dynamic UICollectionView/UITableView/UITextView
341
381
342
382
There are some special cases where you may need to resize the row according to the changing content in your view controller's view.
@@ -375,7 +415,10 @@ public class PricingVC: UIViewController, ScrollStackContainableController {
375
415
376
416
In this way as you add new value to the table the size of the row in stack view will grown.
377
417
418
+
[↑ Back To Top](#index)
419
+
378
420
<aname="rowsseparator"/>
421
+
379
422
#### Rows Separator
380
423
381
424
Each row managed by `ScrollStack` is of a subview class of type `ScrollStackRow`. It has a strong referenced to managed `UIViewController` but also have a subview on bottom called `ScrollStackSeparator`.
@@ -391,7 +434,10 @@ Moreover you can set these values directly on `ScrollStack` controller in order
391
434
392
435
`ScrollStack` also have a property called `autoHideLastRowSeparator` to hide the last separator of the stack automatically.
393
436
437
+
[↑ Back To Top](#index)
438
+
394
439
<aname="taponrows"/>
440
+
395
441
#### Tap On Rows
396
442
397
443
By default rows are not tappable but if you need to implement some sort of tap features like in `UITableView` you can add it by setting a default callback for `onTap` property on `ScrollStackRow` instances.
@@ -426,7 +472,10 @@ class GalleryVC: UIViewController, ScrollStackRowHighlightable {
426
472
427
473
Transition between highlights state will be animated automatically.
428
474
475
+
[↑ Back To Top](#index)
476
+
429
477
<aname="installation"/>
478
+
430
479
### Installation
431
480
432
481
`ScrollStackContainer` can be installed with CocoaPods by adding pod 'ScrollStackContainer' to your Podfile.
@@ -437,8 +486,10 @@ pod 'ScrollStackContainer'
437
486
438
487
It also supports `Swift Package Maneger` aka SPM.
439
488
489
+
[↑ Back To Top](#index)
440
490
441
491
<aname="authorlicense"/>
492
+
442
493
### Author & License
443
494
444
495
`ScrollStackContainer` is developed and maintained by:
@@ -450,3 +501,6 @@ I fully welcome contributions, new features, feature requests, bug reports, and
450
501
`ScrollStackContainer` is released under the MIT License.
451
502
It was originally inspired by [`AloeStackView`](https://github.com/airbnb/AloeStackView) by Airbnb.
0 commit comments