Bird
0
0

You want to display a horizontally scrolling list of 1000 images efficiently. Which approach is best to keep your app fast and memory-friendly?

hard📝 Application Q15 of 15
iOS Swift - SwiftUI Layout
You want to display a horizontally scrolling list of 1000 images efficiently. Which approach is best to keep your app fast and memory-friendly?
AUse ScrollView with LazyHStack and load images lazily inside ForEach
BUse ScrollView with HStack and load all 1000 images immediately
CUse VStack with LazyVStack inside ScrollView
DUse List with VStack and load images eagerly
Step-by-Step Solution
Solution:
  1. Step 1: Understand lazy loading for large lists

    LazyHStack inside ScrollView creates views only when needed, saving memory for large lists.
  2. Step 2: Compare with eager loading

    HStack or VStack loads all views immediately, which is slow and memory-heavy for 1000 images.
  3. Step 3: Confirm horizontal scrolling

    LazyHStack arranges items horizontally and works well with horizontal ScrollView.
  4. Final Answer:

    Use ScrollView with LazyHStack and load images lazily inside ForEach -> Option A
  5. Quick Check:

    LazyHStack + ScrollView for large horizontal lists = C [OK]
Quick Trick: Use LazyHStack inside ScrollView for large horizontal lists [OK]
Common Mistakes:
  • Using HStack loads all views immediately
  • Confusing vertical and horizontal stacks
  • Using List when horizontal scrolling is needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes