Bird
0
0

You want to present a full screen modal that shows user profile details and requires a close button to dismiss. Which SwiftUI code snippet correctly implements this behavior?

hard📝 navigation Q15 of 15
iOS Swift - Navigation
You want to present a full screen modal that shows user profile details and requires a close button to dismiss. Which SwiftUI code snippet correctly implements this behavior?
AUse <code>.sheet(showProfile) { ProfileView() }</code> and rely on swipe to dismiss.
BUse <code>.sheet(isPresented: $showProfile) { ProfileView() }</code> with a close button inside ProfileView.
CUse <code>.fullScreenCover(showProfile) { ProfileView() }</code> without a close button.
DUse <code>.fullScreenCover(isPresented: $showProfile) { ProfileView() }</code> and add a close button inside ProfileView that sets <code>showProfile = false</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Choose correct presentation style

    A full screen modal requires fullScreenCover, not sheet.
  2. Step 2: Implement dismissal method

    Since fullScreenCover does not support swipe to dismiss, a close button inside ProfileView must set showProfile = false.
  3. Final Answer:

    Use .fullScreenCover(isPresented: $showProfile) { ProfileView() } and add a close button inside ProfileView that sets showProfile = false. -> Option D
  4. Quick Check:

    Full screen + manual close button = A [OK]
Quick Trick: Full screen modals need manual close button inside view [OK]
Common Mistakes:
  • Using sheet for full screen modal
  • Omitting $ in binding
  • Relying on swipe to dismiss fullScreenCover

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes