gpt4 book ai didi

objective-c - cocos2d 中的 UIActivityIndi​​catorView

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:32:32 24 4
gpt4 key购买 nike

大家好!
目前正在探索 cocos2d 框架。
现在我正在尝试在 cocos2d 项目中使用 UIKit 的东西。

我在做什么:我添加了方法:

    -(void)activityIndicatorRun {
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.color = [UIColor orangeColor];
spinner.hidesWhenStopped = YES;
[spinner startAnimating];
[self scheduleOnce:@selector(activityIndicatorStop) delay:5.0f];
}

-(void)activityIndicatorStop {
[spinner stopAnimating];
}

在我将这段代码添加到我的init 方法之后:

[self scheduleOnce:@selector(activityIndicatorRun) delay:54];

我想我需要在我的 View 中添加一个 subview 。但我不确定你如何做到这一点,以及在哪里。

问题:谁能帮帮我?

提前致谢!

最佳答案

您可以在 cocos2d 应用程序中添加 UIKit 组件作为底层 OpenGL ES View 的 subview 。

对于 cocos2d-iphone 0.99/1.0:

[[[CCDirector sharedDirector] openGLView] addSubview:spinner];

对于 2.x:

// CCDirector is subclass of UIViewController in 2.x on iOS
[[[CCDirector sharedDirector] view] addSubview:spinner];

关于objective-c - cocos2d 中的 UIActivityIndi​​catorView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10501448/

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