UISplitViewController - Hide Master Slideshow

My application has a UICollectionViewControllermain view in its controller. When the device is in portrait orientation, the user can scroll the screen to open the main view.

When a collection cell is selected, the detail view is updated with new data. Now I would like the main view to automatically hide at the same time. Is it possible?

+3
source share
2 answers

Found an answer on the Apple Developer Forum

First, make sure that the detail view controller has a link to the popup view:

- (void)splitViewController:(UISplitViewController *)svc
    willHideViewController:(UIViewController *)aViewController
         withBarButtonItem:(UIBarButtonItem *)barButtonItem
      forPopoverController:(UIPopoverController *)pc {
    //Grab a reference to the popover
    self.popover = pc;
}

Then release popover when updating the detail view:

if (_popover != nil) {
    [_popover dismissPopoverAnimated:YES];
}
+2
source

UICollectionViewController

UISplitViewController *splitVC = (UISplitViewController *)self.parentViewController;
    splitVC.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
0

All Articles