1

I am able to simulate a modal view controller by displaying the MvxViewController with MvxModalPresentation attribute, but it doesn't respond to setting its content size or the views height. The presentation is always full frame height minus few pixels - see screenshot. There is an attribute PreferredContentSize, but in the MvvmCross documentation it states that it works on iPad only.

[MvxModalPresentation(
     ModalPresentationStyle = UIModalPresentationStyle.FormSheet,
     WrapInNavigationController = true
 )]
public partial class LogoutViewController : BaseViewController<LogoutViewModel> ...

I tried setting all kinds of UIModalPresentationStyle - that doesn't help, the view is presented in exact same way. Is there a way to actually implement a modal view in MVVMCross as of 2021? This seems like a trivial task to do, yet there's nothing on the web..

enter image description here

Async-
  • 3,140
  • 4
  • 27
  • 49
  • Can't tell how it works in Xamarin but I guess it just uses native implementation and in iOS `preferredContentSize` works only on iPads for styles like `.formSheet` or `.popover`. On iPhones you can only have `.automatic` style (the one you have on your screenshot) or `.fullScreen` which does what it states. You can check all possible styles and description how it's displayed [here](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle/automatic) – ScorpiCon Feb 13 '21 at 10:46
  • thanks for that, the default ones are ok, but i need the modal view covering half a screen. It appears mvvmcross doesn't have that option – Async- Feb 14 '21 at 17:04
  • 1
    @Async- yes it don't have half screen option you need to do create a controller with design with center to bottom and present controlller with full screen. –  Feb 18 '21 at 04:44
  • @RB1509 thanks for that, it actually works like a charm, dismissing it still works with a swipe, since I present it as modal view, and I added a button on top if you tap it outside to dismiss as well. Such an easy solution and it works, thanks! – Async- Feb 18 '21 at 11:45
  • yourviewcontroller.isModalInPresentation = true –  Feb 18 '21 at 11:49
  • set this line where you present controller it will block swipe dismiss. –  Feb 18 '21 at 11:50

0 Answers0