Correct way of showing consecutive modalViews

前端 未结 7 1863
没有蜡笔的小新
没有蜡笔的小新 2020-12-23 23:44

I have two views that need to be shown modally, one after the other. This doesn\'t work if we dismiss and show consecutively, like this:

[rootController dism         


        
7条回答
  •  萌比男神i
    2020-12-24 00:13

    // present modal view inside another presented modal view
    
        FirstViewController *firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: firstVC];
    
        // Note: you can use your viewcontroller instead self.window.rootViewController
    
        [self.window.rootViewController presentViewController:navController animated:YES completion:^{
                    //code...
                        SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    
                        [navController presentViewController: secondVC animated:YES completion:nil];
    
                    }
                }];
    

提交回复
热议问题