0

I have a large code base wherein I have a SwiftUI view and am trying to present a bottom sheet using the following code.

        .sheet(isPresented: $isPresentedSheet, content: {
            Rectangle().foregroundColor(.pink)
        })

For some reason it always shows full screen, and does not support drag down to close. Tested in iOS 13, 14, and 15. If I create a small test app and use the same code, it works correctly. I am not sure why in the larger code base it isn't working. Any ideas?

For the SwiftUI - Half modal suggestion, I'm not sure how that helps my case per se. I want to do something simple, which is to get the sheet modifier to work correctly.

rubenz
  • 21
  • 1
  • 3
  • Check that, in the larger code, there is no extension to `View` that is changing the `.sheet()` modifier. – HunterLion Mar 25 '22 at 07:20
  • I don't think there is. How would that work exactly? By overriding the sheet function you mean? – rubenz Mar 25 '22 at 08:58
  • When I run into these problems, I move the view up the view tree to find the place that is causing the problem. – Phil Dukhov Mar 25 '22 at 09:06
  • Does this answer your question? [SwiftUI - Half modal?](https://stackoverflow.com/questions/56700752/swiftui-half-modal) – lorem ipsum Mar 25 '22 at 11:18
  • 1
    Please provide enough code so others can better understand or reproduce the problem. – Community Mar 25 '22 at 14:18
  • @PylypDukhov tried moving it to the root of the view hierarchy but same problem. – rubenz Mar 27 '22 at 23:08
  • You need to find the difference with a blank project, it can be anything. Remove all unrelated files from build/comment all unrelated code, remove dependencies, etc. – Phil Dukhov Mar 27 '22 at 23:12

1 Answers1

2

I finally figured out the problem. The modalPresentationStyle of .pageSheet was disabled using method swizzling. I have no idea why that is, but at least I know the answer now. Thanks for all the feedback.

rubenz
  • 21
  • 1
  • 3
  • Hey rubenz, any chance you can share the source code of the full screen sheet? – Roman Sterlin Aug 28 '22 at 21:48
  • not sure I get you. Do you want this https://developer.apple.com/documentation/swiftui/view/fullscreencover(ispresented:ondismiss:content:)? – Ruben Aug 29 '22 at 23:46