Bird
0
0

You want to present a modal that appears as a full screen cover on iPhone but as a sheet on iPad. Which SwiftUI approach achieves this behavior?

hard📝 navigation Q8 of 15
iOS Swift - Navigation
You want to present a modal that appears as a full screen cover on iPhone but as a sheet on iPad. Which SwiftUI approach achieves this behavior?
AUse <code>.sheet(isPresented: $showModal) { ... }</code> with <code>.presentationDetents([.medium, .large])</code> on iPad and <code>fullScreenCover</code> on iPhone
BAlways use <code>fullScreenCover</code> regardless of device
CUse <code>.sheet</code> only and rely on system default presentation
DUse <code>.popover</code> modifier for all devices
Step-by-Step Solution
Solution:
  1. Step 1: Understand platform differences

    On iPad, sheets can have detents for partial/full height; on iPhone, fullScreenCover is often preferred.
  2. Step 2: Conditional modifier usage

    Use .sheet with detents on iPad and fullScreenCover on iPhone.
  3. Step 3: Implement platform checks

    Use UIDevice.current.userInterfaceIdiom or horizontalSizeClass to switch modifiers.
  4. Final Answer:

    Use .sheet with detents on iPad and fullScreenCover on iPhone -> Option A
  5. Quick Check:

    Combine sheet detents and fullScreenCover by device [OK]
Quick Trick: Use sheet with detents on iPad, fullScreenCover on iPhone [OK]
Common Mistakes:
  • Using only fullScreenCover everywhere
  • Ignoring device idiom differences
  • Using popover instead of sheet/fullScreenCover

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes