概述
为了防止操作组件时cocos2d的动画停止不动,找到CCDirectorIOS.m文件,找到如下代码:
//
// If you want to attach the opengl view into UIScrollView
// uncomment this line to prevent 'freezing'.
// It doesn't work on with the Fast Director
//
// [[NSRunLoop currentRunLoop] addTimer:animationTimer
//
去掉注释。然后在AppDelegate.m中华将下面代码注释:
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
创建一个UIViewController类,名字为: MyUIViewController
自己根据需要添加内容
然后修改HelloWorldLayout.m
-(id) init
{
if( (self=[super init])) {
MyUIView *view = [[MyUIView alloc] initWithNibName:@"MyUIView" bundle:nil];
[[[CCDirector sharedDirector] openGLView] addSubview:view.view];
}
return self;
}
删除添加的组件:
[self.updateUIView.view removeFromSuperview];
这样后还要加上[self.updateUIView.view release];这样才真正的从内存中释放掉~
转载于:https://www.cnblogs.com/gtts/archive/2012/03/25/2416368.html
最后
以上就是超帅八宝粥为你收集整理的在cocos2d中添加UIKit组件的全部内容,希望文章能够帮你解决在cocos2d中添加UIKit组件所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复