uinavigationcontroller - 在CCLayer中添加UINavigationController

标签 uinavigationcontroller crash cocos2d-iphone cclayer

我正在尝试创建一个应用程序,该应用程序使用 cocos2d 作为主屏幕,并使用 UINavigationController 来显示某些表格和信息。我使用此代码尝试将 UINavigationController (设置)插入 View

UINavigationController *controller = [[UINavigationController alloc] init];
Settings *newTableViewController = [[Settings alloc] init];
[controller pushViewController:newTableViewController animated:YES];

这段代码在CCLayer中执行,Settings是一个UINavigationController。

我收到此错误

*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“不支持推送导航 Controller ”

这是否意味着我无法将 NaviagationController 推送到 CCLayer 中? 请帮忙。

最佳答案

您不能“将 View Controller 推送到 CCLayer”。您使用 cocos2d 所做的所有操作都发生在一个 OpenGL View 中。

如果您确实想做这样的事情,您可以更改应用程序 Root View Controller 的创建。让您的应用程序 View Controller 成为 UINavigationController 而不是 UIViewController 的子类,然后只需从应用程序委托(delegate)中获取 rootViewController 并在需要时将任何其他 View Controller 推送/弹出到它。无论如何,我不认为这是一个好主意。

关于您的异常,我假设您的 Settings 类是 UINavigationController 的子类。您想要推送到导航 Controller 的所有 Controller 都必须从 UIViewController 派生,而不是 UINavigationController。

关于uinavigationcontroller - 在CCLayer中添加UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13617221/

相关文章:

iphone - 如何引用 uinavigationcontroller 堆栈中前面的 viewcontroller 属性?

ios - 有时 Sprite 在接触另一个 Sprite 时会被推开

ios - 仅用于碰撞检测的 Box2D

ios - 仅在iPod中崩溃

iphone - 如何在 box2d 中停止作用在物体上的力

ios - 如何在 swift 5 的 navigationController 中向后移动自定义按钮

ios - 当视觉效果 View 位于其顶部时,过渡时显示意外的背景图像

ios - 导航栏标题和 View Controller View 之间弹出窗口中的额外蓝色部分

ios - EXC_RESOURCE 崩溃并不总是显示在 iOS 8 上,有很多线程唤醒?

ios - 如何符号化苹果评论者发送的崩溃日志?