UISplitViewController and Modal view controller presentation issues - ios

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.

Related

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

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?

iOS View controller's view alpha

Can I reveal the underlying view (or the view at the back of a view controller), by making a view controller's view transparent? I tried and it just fades to black and doesn't reveal anything behind it.
Reason?
EDIT:
Okay, this question needs more context.
I have a view controller. Now I am going to present another view controller(simple presentation of view controller, modally). After the new view controller has been presented, I am making its view transparent with alpha=0. Why does it not reveal the underlying view controller's view?
Will using the iOS 7 Transition API help?
If you present your view controller modally (using presentViewController:animated:completion:) then the presenting view controller's view will be removed removed from the window, therefore you cannot see through your presented view controller to the presenting view controller. You might want to use child view controller: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html
Alternatively, you can present your view controller inside a new UIWindow.
You cannot see the original view controller because you use -presentViewController:animated:completion: which will hide the presenting view controller after the animation finished.
You can set the modalPresentationStyle to one of UIModalPresentationOverCurrentContext, UIModalPresentationOverFullScreen and UIModalPresentationCustom before you called 'presentViewController:animated:completion' so that the underlying presenting view controller will not be hidden.
If you would like to have the same background image showing below all UIViewController you can add a UIImageView to the [UIApplication sharedApplication].window in the applicationdidfinishlaunching method

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

Problems presenting modal view controller over UISplitViewController

I have a requirement to present a modal ViewController over a UISplitViewController (i.e. obscuring both the master and detail views, when in landscape).
My code is based on Apple's sample code for Multiple Detail Views, and I've added the presentModalViewcontroller to didFinishLaunching.
To present the modal view, I've used this,
[self.window.rootViewController presentModalViewController:entryView animated:NO];
and this,
[[self.splitViewController.viewControllers objectAtIndex:0] presentModalViewController:entryView animated:NO];
...and both behave in the same way (explained below).
The modal view is presented as I intend, i.e. the view pops up and covers the UISplitView as required. All good so far.
However, as a consequence of presenting the modal view, iOS calls willHideViewController for the obscured UISplitViewController master view. I guess that's reasonable, as the master view is being hidden.
The real problem occurs when the modal view is dismissed, because willShowViewController is NOT called to undo the changes made in willHideViewController (i.e. remove the popover button added to the detail view when the master view was hidden).
This unwanted popover button then sits there, on my Detail view navbar, generally causing a nuisance.
Any thoughts on how to get willShowViewController to be called when the modal view is dismissed, or to otherwise fix this issue would be appreciated.

iOS 5 split view modal view controller popup: possible or no dice?

I basically have a splitview controller and immediately I would like to show a popup modal view controller.
I have wired up the UISplitView class with a modal segue to my other view controller (LoginView, just a straight UIViewController subclass) I basically just want to show that on load and I'm pretty sure I shouldn't do this in the app delegate (however I could be wrong)
I want to do it with a
[something performSegueWithIdentifier:#"login" sender:something];
Where should I put it and what should I connect the segue to (I swear I have tried every different combination haha!)
(I'm using the universal master-detail view starting project from Xcode 4.2)
I would display this from your initial detail view controller (the right pane of your split view) since it will always be sent a -viewDidAppear: message regardless of launch orientation.
In your -viewDidAppear: method, have the split view controller present the modal controller. Each view controller in a split view controller will already have its splitViewController property set. Ensure that your segue is connected from the split view controller (not one of its child view controllers) to the login view controller.
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.splitViewController performSegueWithIdentifier:#"login" sender:self.splitViewController];
}

Resources