Bird
0
0

Identify the error in this SwiftUI grid code:

medium📝 Debug Q6 of 15
iOS Swift - SwiftUI Layout
Identify the error in this SwiftUI grid code:
LazyVGrid(rows: [GridItem(.fixed(100))]) {
  Text("One")
  Text("Two")
  Text("Three")
}
AGridItem should be .flexible() not .fixed()
BLazyVGrid requires columns parameter instead of rows
CMissing ForEach to iterate items
DText views cannot be direct children of LazyVGrid
Step-by-Step Solution
Solution:
  1. Step 1: Check grid parameters

    LazyVGrid accepts columns parameter, not rows.
  2. Step 2: Eliminate other options

    .fixed() is valid for GridItem; ForEach is not required for static views; Text views can be direct children.
  3. Final Answer:

    LazyVGrid requires columns parameter instead of rows -> Option B
  4. Quick Check:

    LazyVGrid = columns parameter [OK]
Quick Trick: LazyVGrid uses columns parameter, not rows [OK]
Common Mistakes:
  • Assuming ForEach is mandatory
  • Confusing columns and rows parameters
  • Thinking Text cannot be direct children

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes