I am googling from a long time, but not get the solution, In iOS 5.1 Master View Comes on right swipe, and disappear on left swipe.
I wants load master view on button click of Detail view, How it is possible?
below code is worked for me, Master view hide, but a black screen size of Master view remain in place of Master view.
- (void)hideMaster:(BOOL)hide {
AppDelegate *appDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
UISplitViewController* spv = appDelegate.splitViewController;
spv.delegate=self;
self.hiddenMaster= hide;
[spv willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
[spv.view setNeedsLayout];
}
- (BOOL)splitViewController:(UISplitViewController*)svc shouldHideViewController: (UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {
NSLog(@"Spv: I do %@show the master", (self.hiddenMaster?@"not ":@""));
return self.hiddenMaster;
}
Thanks in advance
The standard way, as I understand it, to do this is:
In your app delegate file you need to set one of your initial View Controllers to be the UISplitViewControllerDelegate. If you don't do this here you won't get the very first button if you start the app in portrait orientation. For example:
UINavigationController *masterNavigationController = [self.splitViewController.viewControllers objectAtIndex:0];
MyMasterVC *master = [self.masterNavigationController.viewControllers objectAtIndex:0];
self.splitViewController.delegate = master;
In MyMasterVC.h declare yourself as the <UISplitViewControllerDelegate>
by amending the interface, such as:
@interface MyMasterVC : UIViewController <UISplitViewControllerDelegate>
In MyMasterVC.m you need to implement the various methods of the UISplitViewControllerDelegate which are described here in Apple's documentation
The methods to hide and show the view controller give you a UIBarButtonItem which you must then add to, or take away from, your Detail View Controller (In, for instance, a UIToolBar or UINavigationBar).
If you have problems dealing with that, it is covered pretty well in one of the lectures on iTunesU by the excellent Paul Hegarty of Stanford University (Fall 2010 or 2011 - can't remember). You should really take a look. iOS5.1 has changed the way the MasterVC is presented from the strict "popover" way in the course, but I think the methods described will still work. It's quite early in the course, maybe lecture 5 or 6 or 7 or something like that. I think it's called Split Views, or iPad Split Views or similar.
EDIT: It's lecture 7, and it's called: "UIToolbar and iPad Apps"