I'm updating an existing project done using a stack view, current structure looks something like this
- View
-- Scroll View
--- Stack view
---- InputView
----- Text Field
---- InputView
----- Text Field
---- InputView
----- Text Field
I need to add in some table rows elements to this, I understand that it's not best practice to add a table view into a stack view as below
- View
-- Scroll View
--- Stack view
---- InputView
----- Text Field
---- Table view
----- Cell
My question is, what can I do to introduce Table Rows into the current Stack View structure without rebuilding the entire thing as a Table view. Rebuilding it will take some time and impacts other areas on the project.
CodePudding user response:
By default, SwiftUI’s VStack and HStack load all their contents upfront, which is likely to be slow if you use them inside a scroll view. If you want to load content lazily – i.e., only when it scrolls into view, you should use LazyVStack and LazyHStack as appropriate.
CodePudding user response:
You don't need to re-build it , Firstly make the scroll of table view inside scroll view, so the table view take space of that 4 text-box you have removed and want to keep table view. If you make table view scrollable you can keep as much data you want.
To introduce Table Rows into the current Stack View structure play with some heights constrain and also you can make input view side by side .