yes you can do that but u need to create seperate view controller for master and detail
create new project as split view controller and remove split view from xib so that we are creating split view from code .
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
self.splitViewController =[[UISplitViewController alloc]init];
self.rootViewController=[[RootViewController alloc]init];
self.detailViewController=[[DetailViewController alloc]init];
UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController];
// Add the split view controller's view to the window and display.
self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil];
self.splitViewController.delegate=detailViewController;
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
return YES;
}
where rootviewcontroller is ur form one and detail view controller is ur form two.
in detail view controller ie ur form two create class variable
SplitViewAppDelegate *appDelegate; //id ur app delegate variable
set property and synthesize it.
then in ur form two
- (void)viewDidLoad {
self.appDelegate = (SplitViewAppDelegate *)[[UIApplication sharedApplication] delegate];
}
and finally while pushing ur form three
- (IBAction)pushViewController:(id)sender{
NSLog(@"%@",self.appDelegate.splitViewController.viewControllers);
RootLevel1 *rootLevel1 =[[RootLevel1 alloc]init];//create form 1 root vc and assign form 1 vc
DetailLevel1 <UISplitViewControllerDelegate>*detailLevel1=[[DetailLevel1 alloc]init];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
initWithTitle: @"Home"
style:UIBarButtonItemStylePlain
target:self
action:@selector(home)];
rootLevel1.navigationItem.leftBarButtonItem=backButton;
[self.appDelegate.splitViewController viewWillDisappear:YES];
[[self.appDelegate.splitViewController.viewControllers objectAtIndex:0] pushViewController:rootLevel1 animated:YES];
[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] pushViewController:detailLevel1 animated:YES];
self.appDelegate.splitViewController.delegate = detailLevel1;
[self.appDelegate.splitViewController viewWillAppear:YES];
}
and for poping view controller
-(void)home {
[self.splitViewController viewWillDisappear:YES];
[[self.appDelegate.splitViewController.viewControllers objectAtIndex:0]popViewControllerAnimated:YES];
[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1]popViewControllerAnimated:YES];
UIViewController <UISplitViewControllerDelegate>*viewController=[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] visibleViewController];
self.splitViewController.delegate=viewController;
[self.splitViewController viewWillAppear:YES];
}
set ur splitview delgeate accordingly.