title: iOS: UISplitViewController show/hide master view button doesn't work
body: <p>I am learning objective C. Now I am curios with UISplitViewController and show/hide master view button. I have seen a lot of tutorial but I do something wrong and I don't know what is it. My button doesn't hide master view. I absolutely broke my mind in two days. Now I built this sample project to ask your advice.
  In my pattern I have: TabBarVC, SplitVC, TableViewVC and ViewVC. All controllers are my custom.
  MyTabBarViewController is coming first. I has the tab with UISplitViewController.</p>
  
  <p>MySplitViewController.m</p>
  
  <pre><code>#import "MySplitViewController.h"
  #import "MyTabBarViewController.h"
  #import "MyDetailViewController.h"
  
  @interface MySplitViewController ()
  
  @end
  
  @implementation MySplitViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      MyTabBarViewController *masterVC = [self.storyboard instantiateViewControllerWithIdentifier:@"myTableVC"];
      MyDetailViewController *detailVC = [self.storyboard instantiateViewControllerWithIdentifier:@"myDetailVC"];
  
      NSArray *newViewControllersArray = [NSArray arrayWithObjects:masterVC, detailVC, nil];
  
      self.viewControllers = newViewControllersArray;
  
  }
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
  }
  
  
  @end
  </code></pre>
  
  <p>MyTableViewController.m</p>
  
  <pre><code>#import "MyTableViewController.h"
  
  @interface MyTableViewController ()
  
  @end
  
  @implementation MyTableViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      self.dataArray = [[NSArray alloc] initWithObjects:@"1", @"2", nil];
  }
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
  }
  
  #pragma mark - Table view data source
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      return 1;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return [self.dataArray count];
  }
  
  //configure the cell
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
  
      cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
  
      return cell;
  }
  
  @end
  </code></pre>
  
  <p>MyDetailViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface MyDetailViewController : UIViewController &lt;UISplitViewControllerDelegate&gt;
  @property (weak, nonatomic) IBOutlet UIBarButtonItem *showHideMasterVC;
  @property (nonatomic, strong) UIPopoverController *popover;
  
  @end
  </code></pre>
  
  <p>MyDetailViewController.m</p>
  
  <pre><code>#import "MyDetailViewController.h"
  
  @interface MyDetailViewController ()
  
  @end
  
  @implementation MyDetailViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
  }
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  -(void)splitViewController:(UISplitViewController *)svc
      willHideViewController:(UIViewController *)aViewController
           withBarButtonItem:(UIBarButtonItem *)barButtonItem
        forPopoverController:(UIPopoverController *)pc
  {
      //Grab a reference to the popover
      self.popover = pc;
  }
  
  -(void)splitViewController:(UISplitViewController *)svc
      willShowViewController:(UIViewController *)aViewController
   invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
  {
      //Nil out the pointer to the popover.
      _popover = nil;
  }
  
  @end
  </code></pre>
  
  <p>Here's my whole project with storyboard: <a href="https://dl.dropboxusercontent.com/u/1338320/SplitVCTest.zip" rel="nofollow">MyProject</a></p>
  
  <p>Sorry for a lot of code, but please help me or I get crazy. Thank you!
  PS By the way is it possible to have show/hide master view button outside NavigationController, on some view for example?</p>
  
  <p>And now I got that - (void)splitViewController(UISplitViewController *)svc willHideViewController and - (void)splitViewController(UISplitViewController *)svc willShowViewController is deprecated in iOS8.</p>
  
  <p>So can somebody correct my project what I should do for solving my problem?</p>