0
votes

I've discovered that after dismissing a modal view controller that's presented fullscreen in a compact view and as a popover in a horizontally regular view, the screen goes black after the animation.

My View Hierarchy is the following

View (of my rootViewController on the window)
--->UISplitViewController.view ( set as a child viewController )
--------> rootViewController.view (set as the mainViewController of the splitView)
--------> detailViewController.view (set as the detailViewController of the split view)

Via the iPhone 6 simulator(split view is always collapsed) I present a modal viewcontroller with the following code:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];  
[navigationController.navigationBar setBarStyle:UIBarStyleBlack];  
[navigationController setModalPresentationStyle:UIModalPresentationPopover];  

navigationController.popoverPresentationController.sourceView = view;  
navigationController.popoverPresentationController.barButtonItem = barButtonItem;  
navigationController.popoverPresentationController.delegate = self;  

[self presentViewController:nav animated:YES completion:nil];  

I dissmiss the presented controller from that viewController by calling:

[self dismissViewControllerAnimated:true completion:nil];

If I set animated to "false" I dont have any problems, but it looks bad and doesnt make sense.

I see some posts regarding this and custom presenatation methods, but I'm not using anything custom here.

On iPhone the ModalPresentationStyle should default to UIModalPresentationOverFullScreen, so I tried setting the presentationStyle directly to that, and it worked! If I set the presentationStyle to "FullScreen" (not over fullscreen) I get the same behavior, a black screen after dismissing.

Any thoughts or experiences on this one?

1

1 Answers

0
votes

I've come up with the following work around, but I still don't think it should be needed.

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection{
    if( traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact )
    {
        return UIModalPresentationOverFullScreen;
    }
    else
    {
        return UIModalPresentationPopover;
    }
}