0

I've implemented a UISpliview and it works great. But I would like to add an option for the users to dismiss the masterview by pressing a button in the masterview (so it would be doing the same action, which is trickered by touching the detailview). Is this possible to do? I've update with the code, which I believe should work, but it doesn't do anything?

- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem = _backButton;
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}

- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:  (UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil; 
}

//the action, which gets called once the button is pressed. 
- (IBAction)backToFullDetailView:(id)sender
{
    [self.masterPopoverController dismissPopoverAnimated:YES];
}

Masterview shown with button (help)

Niels Sønderbæk
  • 3,487
  • 4
  • 30
  • 43

1 Answers1

0

I believe you need to dismiss your popover. A similar question has been asked here. You are looking at something like [youPopoverController dismissPopoverAnimated: YES];

Community
  • 1
  • 1
tiguero
  • 11,477
  • 5
  • 43
  • 61
  • How is a popover connected to a `UISplitViewController`? – Till Sep 16 '12 at 15:10
  • it is a property of the detail view controller: self.masterPopoverController – tiguero Sep 16 '12 at 15:30
  • I have never seen such property within the UIKit references. Could you please quote the relevant part from the documentation? – Till Sep 16 '12 at 15:32
  • I got it by creating a SplitViewController template - i don't recall to have seen it in the official doc – tiguero Sep 16 '12 at 16:16