questionViewController

questionViewController

在父级ViewController中使用以下代码,我想在第一个 View 之上显示第二个 View ,然后关闭第一个 View :

// Animates the next questionViewController using the first questionViewController
[previousView presentViewController:nextQuestionViewController animated:YES completion:nil];

// Dismiss the first questionViewController
[previousView dismissViewControllerAnimated:NO completion:nil];

运行时,将显示第二个 View ,但不会关闭第一个 View 。

最佳答案

您需要首先关闭“previousView”,然后显示“nextQuestionViewController”:

// Dismiss the first questionViewController
[previousView dismissViewControllerAnimated:NO completion:nil];

// Animates the next questionViewController using the first questionViewController
[previousView presentViewController:nextQuestionViewController animated:YES completion:nil];

10-08 19:02