Why does a modal view controller disappear after switching apps? - ios

I am displaying a modal view controller in my app. When I switch to a different app and then back to mine, the modal view controller is no longer displayed, what I see instead is the view behind it.
I know that the modal view controller is still in the view hierarchy and is simply not drawn, because I can call dismissModalViewController on the parent view controller and the app will behave correctly (if I don't call dismissModalViewController, displaying another modal view controller puts the app into a weird state).
Has anyone else encountered this? What can be done to fix it?

There is a thing you should try: try using some "well known" View Controller instead of the one you display and see if you get the same result with disappearance. Like UIImagePickerViewController

Related

What is the best way to present a view controller on top of everything in iOS?

I'm trying to present a view controller that will be kept displayed above everything, regardless of the currently presented view controller, so it will be kept as displayed even if the view controller behind it will get dismissed, or starts to present another view controller.
I know how to find the topmost view controller (for example as suggested here) but in this case presenting over this view controller will make the new view controller depends on the hierarchy of the parent controller, which I try to avoid.
Present the view from the rearmost view, the window. But give it a high z index so that it shows up in front of everything else.

Dismissing Modal View Controller Causes Multiple VC's to Close

This question is hard for me to ask without a reference, so please see the image above. I am trying to dismiss the modal view controller on the far right of my storyboard.
The problem is when the view controller on the right hand side it dismissed and the user is returned to the middle view controller in the storyboard above, then immediately the next two view controllers are dismissed and the user is returned to the left most view controller.
I have only called the dismiss method on the right most view controller. I am wondering why this happens?
I have fiddled with the kind and presentation style of the segue to no avail. I have also tried using delegation and calling the dismiss method in the presenting view controller. This still results in the same unexpected behavior.
Any help would be great.

QLPreviewController loses touch after presenting a modal view controller over it

In an iPad master-detail application (the master is an UITableViewController and the detail a QLPreviewController) whenever I present a view controller modally and then dismiss it, the QLPreviewController stops receiving touch events or at least reacting to them. So, it's no longer possible to zoom in or out, or "bouncing" an image/document currently being shown, even after another image/document is selected and shown.
Keep in mind that before presenting the view controller modally everything works as expected and it's possible to zoom in/out.
Anyone knows a possible solution for this weird problem?
EDIT: added that this happens after dismissing the view controller presented modally.
EDIT 2: if the presentation style is UIModalPresentationFormSheet, the problem does not occur. It seems to only occur with UIModalPresentationFullScreen.
Although not a solution for this problem, a workaround is to present the view controller as UIModalPresentationFormSheet instead of fullscreen.
Yes that is expected behaviour.
When a ViewController is presented modally (I assume you are presenting something in a form sheet?), it prevents other view controllers receiving touch events.
The other alternative is to have a look at child view controllers as an alternative; but again, their touch events will take precedence over anything underneath.

iPhone popover controller present view controller fullscreen

I am using a third party popover controller on the iphone and have ran across an issue. The one I'm using is WYPopoverController but have tried using FPPopover and it has the same "issue" since they work in a similar way. Here is the deal:
I have a notifications button in my app which pops up a popover controller which contains the notifications feed. It's like the Facebook app. You can see it on the below image.
Now what I want to do it so present a view controller on top of everything and in full screen. The way that popover controller works is that it ads its view directly to the applications main window and its not nested in the view hierarchy so I get a warning saying presenting view controllers on detached view controllers is discouraged and it does not present full screen as well (I know thats logical). If I present it on the parent view controller (the red one in the background) it gets presented below the popover view.
How to fix this?
I was thinking about using a new UIWindow instance and using a root view controller there. Is this an OK solution or is it a hack? If it's ok then how do I accomplish this? I want the presentation and dismissal to be animated :)
I want it to look like Facebok Paper app when you tap an item in the notifications feed.

Data disappears when switching between view controllers

I am writing an iPhone application using the storyboards for an initial mockup. The problem I have right now is switching view controllers.
I have a table view controller and another view controller. All I want to do is use a back button to go back to the original screen, and I can do that, except the data disappears. The storyboard that I have is shown below.
I have the Back button going back to the original navigation controller. I have also had it going back to the Card view controller.
I have hard coded some example cells to just see how things look and they show up just fine when I run the simulation. When I click the back button though, it goes back to the All Cards screen and the cells that were there are now gone.
If I need to post some code just ask for what part would be helpful, I have done all of this through storyboards though.
I'm sure it's something stupid I've done, any point in the right direction would be greatly appreciated.
Basically: you pushed where you should have popped.
What you are seeing on the Storyboard does not exist yet. By segue-waying during runtime to a view controller it gets instantiated.
When you segue-wayed during runtime from the Add Card view controller "back" to the Card View Controller - here is what happened: instead of popping the navigation stack all the way back to the Card View Controller you already had, you just instantiated a new Card View Controller and pushed it onto the navigation stack. You could verify that by going all the way back to the original Card View Controller by tapping the back button several times.
What you could do to accomplish your task is this:
Instead of using the Storyboard for your back button use an IBAction in code:
- (IBAction)popToRoot:(id)sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}

Resources