Bird
0
0

What will be the visible layout result of this SwiftUI code snippet?

medium📝 ui behavior Q4 of 15
iOS Swift - SwiftUI Layout
What will be the visible layout result of this SwiftUI code snippet?
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) {
  ForEach(0..<4) { i in
    Text("Item \(i)")
  }
}
AA grid with 4 columns and 1 row showing items 0 to 3
BA single column list showing items 0 to 3 vertically
CA grid with 2 columns and 2 rows showing items 0 to 3
DA horizontal scrolling grid with 2 rows
Step-by-Step Solution
Solution:
  1. Step 1: Analyze grid columns

    The grid has 2 flexible columns, so items will fill 2 columns per row.
  2. Step 2: Count items and rows

    There are 4 items, so they fill 2 rows (2 items per row).
  3. Final Answer:

    A grid with 2 columns and 2 rows showing items 0 to 3 -> Option C
  4. Quick Check:

    2 flexible columns + 4 items = 2 rows [OK]
Quick Trick: Flexible columns divide items evenly across rows [OK]
Common Mistakes:
  • Assuming single column layout
  • Thinking grid scrolls horizontally
  • Miscounting rows or columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes