gpt4 book ai didi

ios - 在 SpriteBuilder COCOS2d 3.4 中添加 UIViewController

转载 作者:行者123 更新时间:2023-11-30 13:50:31 25 4
gpt4 key购买 nike

我正在尝试将 UIViewcontroller 添加到 SpriteBuilder 项目,以便可以显示其他 UI 项目,但将其添加到主场景时遇到问题。

我创建了 View Controller ,但我所能找到的添加它的是:

[[CCDirector sharedDirector] presentViewController:viewController animated:YES completion:nil];

当我尝试此操作时,Xcode 会尝试拆分该行,因为它认为它是 2 行代码。我猜这是 Obj-C 版本?谁能帮忙解决 Swift 版本吗?

最终我想添加一个 UIMediaPicker 到这个 View Controller 。这是最好的方法吗?或者我可以将媒体选择器直接添加到需要 View Controller 的 COCO2D 场景中吗?

感谢您的帮助。

最佳答案

cocos2d 在自己的 View Controller 中呈现自身。对于 Swift,访问此 View Controller 的语法为:

let view = CCDirector.sharedDirector().parentViewController!.view 
// Returns a UIView of the cocos2d parent view controller.

然后,您可以使用 view.addSubview(UIView view) 方法将 subview 添加到 View Controller 。

关于ios - 在 SpriteBuilder COCOS2d 3.4 中添加 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34347468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com