Bird
0
0

Which code correctly defines the columns array for LazyVGrid?

hard📝 Application Q15 of 15
iOS Swift - SwiftUI Layout
You want to create a grid with 3 columns where the first column is fixed width 100, the second is flexible, and the third is adaptive with minimum 80 width. Which code correctly defines the columns array for LazyVGrid?
A[GridItem(.adaptive(minimum: 80)), GridItem(.fixed(100)), GridItem(.flexible())]
B[GridItem(.flexible()), GridItem(.fixed(100)), GridItem(.adaptive(minimum: 80))]
C[GridItem(.fixed(100)), GridItem(.flexible()), GridItem(.adaptive(minimum: 80))]
D[GridItem(.fixed(100)), GridItem(.adaptive(minimum: 80)), GridItem(.flexible())]
Step-by-Step Solution
Solution:
  1. Step 1: Match column order with requirements

    The first column must be fixed width 100, second flexible, third adaptive minimum 80.
  2. Step 2: Check each GridItem in options

    [GridItem(.fixed(100)), GridItem(.flexible()), GridItem(.adaptive(minimum: 80))] matches order: fixed(100), flexible(), adaptive(minimum: 80).
  3. Final Answer:

    [GridItem(.fixed(100)), GridItem(.flexible()), GridItem(.adaptive(minimum: 80))] -> Option C
  4. Quick Check:

    Order and types must match requirements [OK]
Quick Trick: Order of GridItems matches column order [OK]
Common Mistakes:
  • Mixing order of GridItems
  • Using wrong GridItem types
  • Confusing adaptive with flexible

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes