3

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?

Apurv
  • 17,116
  • 8
  • 51
  • 67
Guilherme
  • 7,839
  • 9
  • 56
  • 99
  • possible duplicate of [How to hide master view in UiSplitviewcontroller in ipad](http://stackoverflow.com/questions/2700453/how-to-hide-master-view-in-uisplitviewcontroller-in-ipad) – Peter DeWeese Feb 11 '14 at 13:29
  • Check the highest scoring (not the selected answer) in the duplicate I noted. – Peter DeWeese Feb 11 '14 at 13:30
  • 1
    @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 Feb 11 '14 at 13:32
  • 1
    Thanks for the clarification. Close vote retracted. – Peter DeWeese Feb 11 '14 at 13:33

2 Answers2

3

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];
}
Guilherme
  • 7,839
  • 9
  • 56
  • 99
0

In the UICollectionViewController you can do

UISplitViewController *splitVC = (UISplitViewController *)self.parentViewController;
    splitVC.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
cvu
  • 482
  • 2
  • 6
  • 20