I have a simple iPad app with MasterviewController with a tableview and and a DetailViewController containing a UIWebView. Then i dragged and dropped a SplitViewController i
I do it like this in the master view controller (TableController):
#import "TableController.h"
#import "ViewController.h"
@interface TableController ()
@property (strong, nonatomic) NSArray * theData;
@property (strong, nonatomic) UIViewController * detailVC;
@end
@implementation TableController
-(void)awakeFromNib {
self.splitViewController.delegate = self;
self.detailVC = self.splitViewController.viewControllers[1];
}
-(void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
NSMutableArray *itemArray = [self.detailVC.toolBar.items mutableCopy];
[itemArray removeObject:barButtonItem];
[self.detailVC.toolBar setItems:itemArray];
}
-(void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc {
barButtonItem.title = @"Master";
NSMutableArray *itemArray = [self.detailVC.toolBar.items mutableCopy];
if (! itemArray) {
itemArray = [NSMutableArray arrayWithObject:barButtonItem];
}else{
[itemArray insertObject:barButtonItem atIndex:0];
}
[self.detailVC.toolBar setItems:itemArray];
}
I added a tool bar in IB to the detail controller, and gave it the IBOutlet, toolBar.