How to make the master view controller and detail view controller in a split view controller push simultaneously

StackOverflow https://stackoverflow.com/questions/23410983

  •  13-07-2023
  •  | 
  •  

Question

How to make the master view controller and detail view controller in a split view controller simultaneously push to another master view controller and another detail view controller in a split view controller, that is to say, how to push a split view controller to another split view controller. Any help or advice would be much appreciated.

Was it helpful?

Solution

man, If I understand what you're asking. you can using notification. the sample code like this:

in the first detail view controller, you can add a button and an event:

UIButton *button ......
[button addtraget:self action: @selector(pushToSecondDetailView) forControlEvents: UIControlEventTouchUpInside];

-(void) pushToSecondDetailView
{
  SecondDetailViewController *secondDVC = [[SecondDetailViewController alloc] init];
  [self.navigationController pushViewController:secondDVC animated:YES];

  //register notificaton
   [[NSNotificationCenter defaultCenter] postNotificationName:kpushToSecondVCtNotification
                                                    object:nil];
}

in first master view controller:

//receive natification
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(pushToSecondMasterVC) name:kpushToSecondVCNotification object:nil];

-(void) pushToSecondMasterVC
{
 SecondRootViewController *secondVC = [[SecondRootViewController alloc]init];

[self.navigationController pushViewController:secondVC animated:YES];

}

last but not least, in your projectname-Prefix.pch file add this code:

#define kpushToSecondVCNotification @"kpushToSecondVCNotification"

that all, good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top