0
0
iOS Swiftmobile~5 mins

LazyVStack and LazyHStack in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a LazyVStack in SwiftUI?
A LazyVStack is a vertical stack view that loads its child views only when they are about to appear on screen, improving performance for long lists.
Click to reveal answer
beginner
How does LazyHStack differ from a regular HStack?
LazyHStack loads its child views lazily, meaning it creates views only when needed during horizontal scrolling, unlike HStack which creates all views at once.
Click to reveal answer
intermediate
Why use Lazy stacks instead of regular stacks in SwiftUI?
Lazy stacks improve app performance and reduce memory use by creating views only when they are visible, which is helpful for long or scrollable lists.
Click to reveal answer
intermediate
Can you nest LazyVStack inside LazyHStack? Why would you do this?
Yes, nesting LazyVStack inside LazyHStack allows creating complex scrollable layouts that load views lazily both vertically and horizontally, saving resources.
Click to reveal answer
beginner
What happens if you use LazyVStack without a ScrollView?
Without a ScrollView, LazyVStack behaves like a regular VStack because all views fit on screen, so lazy loading has no effect.
Click to reveal answer
What is the main benefit of using LazyVStack in SwiftUI?
ACreates views faster by loading all at once
BImproves performance by loading views only when needed
CAutomatically styles views with shadows
DDisables scrolling in the stack
Which container is needed to enable scrolling with LazyHStack?
AZStack
BVStack
CScrollView with horizontal axis
DList
What happens if you put a LazyVStack inside a ScrollView?
ALazyVStack becomes horizontal
BViews load all at once immediately
CScrollView disables lazy loading
DViews load lazily as you scroll vertically
Which of these is NOT a feature of LazyHStack?
AAutomatically adds padding between views
BLoads views lazily during horizontal scroll
CImproves memory usage for large lists
DRequires ScrollView for scrolling
Why might you choose LazyVStack over VStack?
ATo improve performance with many child views
BTo disable scrolling
CTo add animations automatically
DTo change text color
Explain how LazyVStack improves app performance compared to VStack.
Think about how views are created and shown on screen.
You got /4 concepts.
    Describe a scenario where using LazyHStack inside a ScrollView is beneficial.
    Imagine a photo gallery you scroll sideways.
    You got /4 concepts.