0
votes

I'am trying to develop a multi-orientation app for iPad's. At landscape mode, the MasterViewController should always visible and I don't have any problem on that. But at portraid mode, I have to create a show/hide method. The main problem is, I cannot use delegate methods which are

-(void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc

and

-(void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem

Because my detailViewController is not a NavigationController and shouldn't be. Also detailViewController cannot have a NavigationItem. Let me explain why:

I want my all pages have a dashboard-like views at the bottom of the screen. So I never change detailViewController. At the top of the screen, I have a Navigation Controller embedded in a container view. So If you selected one of the MasterViewController's tableview items, the NavigationController's rootViewController is changing. That's why I cannot have a Navigation item in detailViewController.

These rootViewControllers have buttons which are passing their states to detailViewController wia a custom delegate method. And this method have to hide/show masterviewcontroller.

I don't want to create some custom views and/or animations or custom popover to achieve this. Can anyone help me?

1

1 Answers

1
votes

Detail View Controller Does not need to be UINavigationController to be delegate to split view.

You can have set DetailViewController as delegate for the UISplitViewController. When the split view will hide the view (portrait) save the popover, which you can later show if needed.

Users might still show it without any button to - with swipe from left side of screen. If it's enough for your app then you don't need to implement the delegate methods.

// In App Delegate or Nib:
splitViewController.delegate = detailViewController;




// In Detail View Controller :

- (void)splitViewController:(UISplitViewController*)svc
     willHideViewController:(UIViewController *)aViewController
          withBarButtonItem:(UIBarButtonItem*)barButtonItem
       forPopoverController:(UIPopoverController*)pc {


    self.popoverController = pc;

    // Update ui 
    ...
 }


 - (void)splitViewController:(UISplitViewController*)svc
     willShowViewController:(UIViewController *)aViewController
  invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {

  self.popoverController = nil;
}


- (void)showMenu {
  [self.popoverController presentPopoverFromRect: ...]
}