【发布时间】:2013-02-06 17:06:56
【问题描述】:
所以我正在使用情节提要创建一个基于 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 中的按钮。
任何帮助将不胜感激。谢谢!
【问题讨论】:
-
IngredientsViewController中有任何按钮可以关闭吗? -
不,我想从 RecipeViewController 中将其关闭,我使用语音控制来关闭它(但这都不是问题,它只是关闭它的实际方法。
标签: ios xcode ipad popup uipopovercontroller