3
votes

My app has a UICollectionViewController in its master view controller. When the device is on portrait orientation, the user can swipe the screen to reveal the master view.

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

2
Check the highest scoring (not the selected answer) in the duplicate I noted.Peter DeWeese
@PeterDeWeese I'm aware of that feature. That will control whether the master view should be hidden or not depending on the orientation. However, I want to control the master view that slides-in (that used to be the pop over), and not the fixed-style master view.Guilherme
Thanks for the clarification. Close vote retracted.Peter DeWeese

2 Answers

3
votes

Found the answer at the Apple Developers Forum

First make sure that the detail view controller has a reference to the popover view:

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

Then dismiss the popover when updating the detail view:

if (_popover != nil) {
    [_popover dismissPopoverAnimated:YES];
}
0
votes

In the UICollectionViewController you can do

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