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
As you noted 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.
118
+
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.
119
+
120
+
#### Removing / Replacing Rows
121
+
122
+
A similar set of APIs are used to remove existing rows from the stack:
123
+
124
+
-`removeAllRows(animated:)`: to remove all rows of the stack.
125
+
-`removeRow(index:animated:) -> UIViewController?`: to remove a specific row at given index. It returns a reference to removed view controller.
126
+
-`removeRows(indexes:animated:) -> [UIViewController]?`: to remove rows at specified indexes from the stack. Removed managed `UIViewController` instances are returned.
127
+
-`replaceRow(index:withRow:animated:completion:)`: replace an existing row with a new row which manage new passed view controller.
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.
165
+
166
+
#### Reload Rows
167
+
168
+
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`).
169
+
170
+
There are three methods:
171
+
172
+
-`reloadRow(index:animated:completion:)`: reload a specific row at index.
173
+
-`reloadRows(indexes:animated:completion:)`: reload a specific set of rows.
174
+
-`reloadAllRows(animated:completion:)`: reload all rows.
175
+
176
+
If your `UIViewController` implements `ScrollStackContainableController` protocol you will get notified inside the class about this request, so you have the opportunity to refresh your data:
You can control the size of your `UIViewController` inside a row of a `ScrollStack` in two ways:
205
+
206
+
- Creating contrains in your `UIViewController`'s view with Autolayout.
207
+
- Implementing `ScrollStackContainableController` protocol in your `UIViewController` class and return a non `nil` value in `scrollStackRowSizeForAxis(:row:in:) -> ScrollStack.ControllerSize?` delegate method.
208
+
209
+
In both case `ScrollStack` class will use only one dimension depending by the active scroll axis to layout the view controller content into the stack (if scroll axis is `horizontal` you can control only the `height` of the row, if it's `vertical` only the `width`. The other dimension will be the same of the scroll stack itself.
0 commit comments