• <legend id='V0W4e'><style id='V0W4e'><dir id='V0W4e'><q id='V0W4e'></q></dir></style></legend>

  • <small id='V0W4e'></small><noframes id='V0W4e'>

      <bdo id='V0W4e'></bdo><ul id='V0W4e'></ul>
    <tfoot id='V0W4e'></tfoot>

        <i id='V0W4e'><tr id='V0W4e'><dt id='V0W4e'><q id='V0W4e'><span id='V0W4e'><b id='V0W4e'><form id='V0W4e'><ins id='V0W4e'></ins><ul id='V0W4e'></ul><sub id='V0W4e'></sub></form><legend id='V0W4e'></legend><bdo id='V0W4e'><pre id='V0W4e'><center id='V0W4e'></center></pre></bdo></b><th id='V0W4e'></th></span></q></dt></tr></i><div id='V0W4e'><tfoot id='V0W4e'></tfoot><dl id='V0W4e'><fieldset id='V0W4e'></fieldset></dl></div>

        如何在 cocos2d 中以编程方式创建新的 UIView?

        时间:2024-08-11

          <small id='ThCdG'></small><noframes id='ThCdG'>

          • <bdo id='ThCdG'></bdo><ul id='ThCdG'></ul>
                <tbody id='ThCdG'></tbody>

                  <tfoot id='ThCdG'></tfoot>
                  <legend id='ThCdG'><style id='ThCdG'><dir id='ThCdG'><q id='ThCdG'></q></dir></style></legend>

                  <i id='ThCdG'><tr id='ThCdG'><dt id='ThCdG'><q id='ThCdG'><span id='ThCdG'><b id='ThCdG'><form id='ThCdG'><ins id='ThCdG'></ins><ul id='ThCdG'></ul><sub id='ThCdG'></sub></form><legend id='ThCdG'></legend><bdo id='ThCdG'><pre id='ThCdG'><center id='ThCdG'></center></pre></bdo></b><th id='ThCdG'></th></span></q></dt></tr></i><div id='ThCdG'><tfoot id='ThCdG'></tfoot><dl id='ThCdG'><fieldset id='ThCdG'></fieldset></dl></div>
                1. 本文介绍了如何在 cocos2d 中以编程方式创建新的 UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在 cocos2d 中以编程方式在按钮单击时创建一个新的 UIView.请帮助我提供一些示例代码.提前致谢.

                  I want to create a new UIView on button click programmatically in cocos2d. Kindly help me with some sample code. Thanks in advance.

                  推荐答案

                  你必须创建一个类似的按钮-

                  You have to create a button like-

                  UIButton* myButton = [UIButton buttonWithType:UIButtonTypeCustom];
                  myButton.frame = CGRectMake(30, 70,100,38); //set frame for button
                  
                  [myButton setTitle:@"subview" forState:UIControlStateNormal];
                  [myButton addTarget:self action:@selector(buttonClicked:)forControlEvents:UIControlEventTouchUpInside];
                  

                  或者您可以使用 CCMenu 作为按钮.

                  Or you can use CCMenu as a button.

                  然后编写事件处理函数-

                  And then write the event handling function-

                  -(void)buttonClicked:(id)sender
                  {
                          UIView *myview=[[UIView alloc] initWithFrame: CGRectMake(0, 0,320,480)];
                          myview.backgroundColor=[UIColor redColor];
                          [[[CCDirector sharedDirector] openGLView] addSubview:myview];
                          [myview release];                   
                  }
                  

                  }

                  这篇关于如何在 cocos2d 中以编程方式创建新的 UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:正确重启/重新初始化半单例 下一篇:Cocos2d-iPhone 与 Box2D:CCPhysicsSprite EXC_BAD_ACCESS

                  相关文章

                  <legend id='CtSIl'><style id='CtSIl'><dir id='CtSIl'><q id='CtSIl'></q></dir></style></legend>

                    <tfoot id='CtSIl'></tfoot>

                      • <bdo id='CtSIl'></bdo><ul id='CtSIl'></ul>

                      <i id='CtSIl'><tr id='CtSIl'><dt id='CtSIl'><q id='CtSIl'><span id='CtSIl'><b id='CtSIl'><form id='CtSIl'><ins id='CtSIl'></ins><ul id='CtSIl'></ul><sub id='CtSIl'></sub></form><legend id='CtSIl'></legend><bdo id='CtSIl'><pre id='CtSIl'><center id='CtSIl'></center></pre></bdo></b><th id='CtSIl'></th></span></q></dt></tr></i><div id='CtSIl'><tfoot id='CtSIl'></tfoot><dl id='CtSIl'><fieldset id='CtSIl'></fieldset></dl></div>
                    1. <small id='CtSIl'></small><noframes id='CtSIl'>