1

When I’m presenting a view, i want to block the new iOS 13 behavior where you can swipe down to dismiss the view. I cannot find a way to do this programmatically. Do you guys have any clue?

Thank you!

Benjamin Clanet
  • 1,076
  • 3
  • 10
  • 17
  • In UIKit you set the modalPresentationStyle to `.fullScreen` instead of the default `.automatic`. Does SwiftUI have something similar? – rmaddy Jul 20 '19 at 16:34
  • I'm thinking you can't. It was easier to add a "dismiss" button for me because I feel it's user-friendly (yep, I still use that term). My best guess? don't "present". SwiftUI is about removing customization, not the opposite. (And to anyone with an answer that uses a `PresentationButton`... er, `PresentationLink`... er, yeah, the `sheet` modifier [really Apple?]... I'll upvote the answer.) –  Jul 20 '19 at 16:59
  • I don’t believe it does, everything is pretty much hidden so... there must be something hacky to do! – Benjamin Clanet Jul 20 '19 at 17:00
  • @dfd don’t present? Really? Aha – Benjamin Clanet Jul 20 '19 at 17:05
  • Well, there are other ways, but most involve `UIKit` or a `NavigationBar`. (And I'm sure someone will prove something I said wrong.) And yep, i'm very annoyed that in *four* - actually *three* - betas we've gone from "button" to "link" to "depricated". (Welcome to the world of being bleeding-edge, Dave.) My most constructive thought - that may work for you - is to first ask *why* you wish to remove the swipe-to-dismiss on a modal view. Is this something that adding a "dismiss" button would suffice? Because **that** I can help you with. –  Jul 20 '19 at 17:19
  • @dfd I’m very annoyed too! Well the reason I want to remove it is because I perform a network request and during that time, I don’t want the user to dismiss it. What would be your dismiss button alternative? – Benjamin Clanet Jul 20 '19 at 17:29
  • It's a dismiss button *along with* a swipe-to-dismiss. Doesn't sound like that helps you. I had a modal view working rather quickly and was stumped for a bit on dismissing it until I realized iOS 13 introduced swipe-to-dismiss. My take? How many people are going to upgrade and get frustrated about something so obscure as this? So I learned how to add a "manual" dismiss button. (Which beta 4 promptly broke because the OS environment variable isn't part of a sheet.) –  Jul 20 '19 at 17:59
  • I think your best route is to create something in `UIKit`, which can tie into your network request more tightly, and then use a "relatable" view for all of it. But that's just a guess. –  Jul 20 '19 at 18:02
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/196752/discussion-between-benjamin-clanet-and-dfd). – Benjamin Clanet Jul 20 '19 at 18:24

0 Answers0