Code creation:
1. appdelegate puts contoller under the controller
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.rootViewController = [[MJOneViewController alloc] init]; [self.window makeKeyAndVisible]; return YES;}2. Actions redirected to oneViewController
Get the controller to jump to, and then use the current controller to call presentViewController
-(IBAction) jump {// display MJTwoViewController * two = [[MJTwoViewController alloc] init]; UINavigationController * nav = [[UINavigationController alloc] callback: two]; [self presentViewController: nav animated: YES completion: ^ {NSLog (@ "indicates that MJTwoViewController has been completed ....... ") ;}] ;}3. twoController returns the previous controller
Call the dismissViewController Method
-(IBAction) cancel {// NSLog (@ "% @", self. view. window. rootViewController); // NSLog (@ "% @", self. view. window. subviews); [self dismissViewControllerAnimated: YES completion: ^ {NSLog (@ "Disable MJTwoViewController .... ") ;}]; // [self. navigationController dismissViewControllerAnimated: YES completion: ^ {// NSLog (@ "Disable MJTwoViewController .... "); //}];}
It is also convenient to create a modal controller on the storyBoard. Press ctrl and right-click to select moadal mode.