Recall & Review
beginner
What is LazyVGrid in SwiftUI?
LazyVGrid is a SwiftUI view that arranges child views in a vertical grid. It loads views only when needed, improving performance for large data sets.
Click to reveal answer
beginner
How does LazyHGrid differ from LazyVGrid?
LazyHGrid arranges child views in a horizontal grid, loading views lazily as they appear on screen, unlike LazyVGrid which arranges vertically.
Click to reveal answer
intermediate
What is the role of
GridItem in LazyVGrid or LazyHGrid?GridItem defines the size and spacing of each column (in LazyVGrid) or row (in LazyHGrid). You can specify fixed, flexible, or adaptive sizes.
Click to reveal answer
intermediate
Why use lazy grids instead of regular grids in SwiftUI?
Lazy grids load views only when they appear on screen, saving memory and improving performance, especially with many items.
Click to reveal answer
beginner
How do you make a grid with 3 equal columns using LazyVGrid?
Create an array of three GridItems with .flexible() size and pass it to LazyVGrid's columns parameter.
Click to reveal answer
Which SwiftUI view arranges items in a vertical grid and loads views lazily?
✗ Incorrect
LazyVGrid arranges items vertically and loads views lazily for better performance.
What does a GridItem with .fixed(100) size mean?
✗ Incorrect
A fixed GridItem has a constant size of 100 points.
Which grid type arranges items horizontally in SwiftUI?
✗ Incorrect
LazyHGrid arranges items horizontally.
Why is lazy loading important in grids?
✗ Incorrect
Lazy loading improves performance by creating views only when they appear on screen.
How do you specify spacing between columns in LazyVGrid?
✗ Incorrect
LazyVGrid has a spacing parameter to set space between columns.
Explain how to create a simple 2-column vertical grid using LazyVGrid in SwiftUI.
Think about how you define columns and place views inside LazyVGrid.
You got /3 concepts.
Describe the benefits of using LazyHGrid over a regular horizontal stack for many items.
Consider what happens when you have many items off screen.
You got /3 concepts.