Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISplitViewController - Hide master slide-in view

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?

like image 378
Guilherme Avatar asked Mar 14 '26 13:03

Guilherme


1 Answers

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];
}
like image 163
Guilherme Avatar answered Mar 16 '26 02:03

Guilherme



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!