xcode - 应用程序尝试以模态方式呈现主动 Controller

标签 xcode uitableview presentmodalviewcontroller ios5

我已经搜索并找到了有关此错误的各种问答,但无法找到针对我的问题的任何具体帮助(至少我的最低经验可以让我理解)。

我正在从应用程序的主菜单加载 UIView,该菜单又具有多个按钮选项(称为子菜单)。其中之一可以毫无问题地返回主菜单([selfmissModalViewControllerAnimated:YES];)。另一个按钮加载 UITableView(单独的 View Controller ),加载效果良好。但是,我想要此 UITableView 中的一个按钮返回到子菜单。当我使用上面提到的代码时,它会一直返回主菜单。我似乎找不到一种方法来创建返回子菜单 UIView(子菜单)的操作。

当我尝试执行标准['uitableviewcontrollername'presentModalViewController:submenuViewanimated:YES];我收到错误应用程序试图以模态方式呈现事件 Controller (我如果我用 self 替换 uitableviewcontrollername ,则会出现相同的错误。

该错误是有道理的,因为我知道它已经处于事件状态,但我需要帮助的是,执行我上面描述的操作的正确方法到底是什么?感谢您抽出时间。

最佳答案

我认为驳回模态视图的正确方法是使用 here 中定义的委托(delegate)。 .

实际上,您在“菜单 View ”上定义一个方法,该方法将通过调用通常的方法来关闭事件模态视图:

- (void) notifytoclose {
    [self dismissModalViewControllerAnimated:YES];
}

您从菜单 View 中调用它,但它将关闭其顶部的事件模式。 然后,您在模式 TableView Controller 上定义一个委托(delegate)属性,将其设置为菜单 View 的实例,并在关闭 TableView 的方法中调用:

[delegate notifytoclose];

尽管我不清楚情况,但使用 [selfmissModalViewControllerAnimated:YES] 关闭当前实例并不总是有效。我还注意到 iPAd 和 iPhone 行为之间的差异。

关于xcode - 应用程序尝试以模态方式呈现主动 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8074766/

相关文章:

ipad - 为什么 [UIViewController presentModalViewController :animated:] transitioning the modal view in from the left?

ios - 移动 WKWebview 框架导致其部分内容变得无响应

ios - Xcode 本地化和国际化 : Exporting for Localization (XLIFF) does not export Info. plist 条目

ios - 单击后无法设置 UITableViewCell 中的 UIButton 图像

ios - 如何在 UITableViewCell UILabel 中使用不同的字体名称

ios - 从 subview 启动时 ImagePickerController 立即被解雇

ios - Xcode 5.0.2 加载时崩溃

swift - Xcode Siri 意图 : How to pass a variable from Intent Handler to IntentUI ViewController without including it in the response

ios - 空的uitableview部分的占位符

ios - 警告 : Attempt to dismiss from view controller <UINavigationController: 0xb359a20> while a presentation or dismiss is in progress