Login Modal view not showing over a splitview using Xamarin iOS and MVVMCross - ios

I'm working on an iPad app using splitview controller and MVVMCross which requires a login screen. I'd like the login screen to appear as a modal popover in the centre of the screen, over the top of the underlying screen which is controlled by a UISplitViewController.Ideally I'd like the 'master' view to be hidden and then appear after a successful login. I understand my UISplitViewController has to be the root controller, so I need to launch the popover from either the master or detail view at an appropriate event

General iOS modal views:
When doing modal views, I tend to do something like this inside the view that we want to be the parent of the modal view.
var myViewController = new UIViewController();
var myModalNavigation= new UINavigationController(myViewController)
{
ModalPresentationStyle = UIModalPresentationStyle.FormSheet,
ModalTransitionStyle = UIModalTransitionStyle.CoverVertical
}
this.PresentModalViewOnTop(myModalNavigation);
We create our view controller, then a navigation controller using the view controller. We give the nav controller a modal presentation and transition style. Then inside the view controller that will launch the modal view we call this.PresentModalViewOnTop();.
In your case in particular, you'd probably want to do this code from your "master view". But you can make it do that inside ViewDidLoad to ensure they can't use your "master view" until the modal has been satisfied and disappeared.
Modal views in MvvmCross:
You'll need to change your presenter logic as MvvmCross assumes every view model is just a normal full "page". There is a great explanation of how to do this here: How do I specify a view to be pushed as Modal in MvvmCross?

Related

With a custom navigation controller push transition, how do I have the previous view controller behind like modal presentations?

When performing a custom modal view controller transition, the view controller you're coming from sits behind the new one nicely (think of Apple's "form sheet" style presentation on an iPad for instance), and when you rotate the device the previous view controller visible in the back rotates as well.
I'm unsure how to get this functionality with a UINavigationController custom push animation. It seems it isn't expected for the previous view controller to be visible from behind and it isn't.
I could take a screenshot, but it won't update on landscape rotation.
How is it done so easily with a modal transition and how do I replicate that for navigation controller custom transitions?
As far as I understand the UINavigationController class such functionality cannot be achieved through it.
UINavigationController is a container controller, which can show only one VC within it at a time. It keeps all the VCs in the stack, but not their views (views are kept by VCs themselves).
Unlike it, the modal presentation is a special type of VC-presentation, and it's not limited by the container-functionality.

UISplitViewController and Modal view controller presentation issues

I am having troubles with an application where I have a split view controller and would like to display a modal view controller over the top.
To test this, I have created a basic project which mimics the structure of my application. I have uploaded this to Github for anyone to download: https://github.com/CaptainRedmuff/SplitViewDemo
There are two main issues which I will detail below:
Issue 1:
When presenting the modal view controller in portrait orientation with the master view controller visible (as a popover I believe), the modal view controller is displayed underneath the master view controller. Any attempts to interact with the model view controller cause the app to crash.
Issue 2:
When presenting the modal view controller from the tab bar controller (in the master view controller), the modal view controller is automatically dismissed when the device is rotated to landscape orientation as the master view controller is removed from the hierarchy.
One possible fix I have found is to conform to the UISplitViewControllerDelegate method - (BOOL)splitViewController:shouldHideViewController:inOrientation: and return NO to force the master view controller to always be visible. This is not the behaviour that I want however so this is not a viable fix.
Considering that there is no way to programatically display or dismiss the master view controller, I am at a loss for alternative methods to present a view controller modally over the top of the entire split view controller.
Before presenting modal VC you must dismiss popover like:
[self.popover dismissPopoverAnimated:NO];
The issue occurred probably because UIPopoverController is added to the window instead of UISplitViewController.

popover UISplitViewController

I'm new to iPad App development (not to iPhone Development). I wish to show a split view controller as a popover when a particular button is clicked [Everything's in interface builder]. So I drag and dropped a Split View Controller and then made a segue from the button to the split view controller. I have set the size of Split View Controller as Form Sheet. Now in the iPad simulator I expect the popover to have both Master View Controller and Detail View Controller, however only the rootViewController (Master) is appearing and there is no scrolling too (in the popover).
How can I show both the master and detail view controller in my popover.
You should not try to do that:
A split view controller must always be the root of any interface you
create. In other words, you must always install the view from a
UISplitViewController object as the root view of your application’s
window.
You can read more about it here

Place button outside Modal View Controller

I would like to add a close button outside the bounds of the modal view controller which I am presenting on an iPad app.
I tried adding a button normally via storyboard, via coding, but the UIButtons view gets clipped by the bounds of the modal view controller.
What my purpose is : I want to add a close button at the right corner of my modal view controller which is configured as a Form sheet.
I'm launching the modal view controller via a segue from my previous view.
Attached screenshot show what I am trying to achieve:

Presenting modal view over partial page curl modal view

I have my main menu embedded in a navigation controller. The settings button performs a modal segue to show my settings page which is half a page shown using the partial page curl.
Now on the settings I have a 'legal' button which I want to just display a full screen UITextView with all my legal stuff.
The problem is, when I display the legal view controller using a modal segue, it displays behind the partial page curl.
If I try using a push segue, it crashes because there is no Navigation controller as the settings is shown modally.
Is there a way to present a modal view over the top of a partial page curl?
Thanks
Best option I can think of is managing all your segues in your initial main menu controller.
For example, you can write a delegate method such that, if the user hits 'legal', you dismiss the modal view (from within your main menu controller's .m) using a delegate method, and then in that same method present a new modal view controller for the settings page (with it's parent being the main menu view controller, which can then have another delegate method to dismiss the legal page and present the settings menu).

Resources