所以我正在使用故事板创建一个基于 ipad 食谱的应用程序。只是为了让您了解我的程序的结构,这里是 View 控制器的流程:
ViewController --Modally--> PreviewViewController --Modally--> RecipeViewController --Popup--> IngredientsViewController
所有这些都在故事板中完成。我创建了IngredientsViewController并将其链接RecipeViewController到 以显示为弹出窗口,效果很好。但是我希望能够以IngredientsViewController编程方式关闭(因为我已经实现了语音命令功能)。问题是我似乎无法访问IngredientsViewController以将其关闭。(抱歉,我还不能发布任何图片)。
我正在使用以下代码以IngredientsViewController编程方式(从内部RecipeViewController)呈现:
[self performSegueWithIdentifier:@"ingr" sender:nil];
哪个可以很好地显示弹出窗口,但我无法将其关闭。我试图通过视图控制器的层次结构访问它,但似乎找不到它,我认为它会位于堆栈的顶部,但显然不是?我试过这样的事情:
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
这又是从内部调用的RecipeViewController。但这只是忽略了弹出窗口呈现的RecipeViewController而不是那个。IngredientsViewController
需要明确的IngredientsViewController是,它不是一个UIPopoverController,它是在故事板中创建的一个正常viewController的,它的 segue 样式是弹出链接到RecipeViewController.
任何帮助将不胜感激。谢谢!