• <tfoot id='ifS3B'></tfoot>

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

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

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

          <bdo id='ifS3B'></bdo><ul id='ifS3B'></ul>

        在 cocos2d 中可以使用 UIPickerView 吗?

        Is it possible to use UIPickerView in cocos2d?(在 cocos2d 中可以使用 UIPickerView 吗?)

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

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

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

                  <tbody id='BznMt'></tbody>
                • <tfoot id='BznMt'></tfoot>

                • <legend id='BznMt'><style id='BznMt'><dir id='BznMt'><q id='BznMt'></q></dir></style></legend>
                • 本文介绍了在 cocos2d 中可以使用 UIPickerView 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 cocos2d 开发 iPhone 2d 游戏.我需要一个选择器.是否可以在 cocos2d 中使用 Picker !如果可能,请告诉我,如何在 cocos2d 中使用 Picker?

                  I am developing iPhone 2d game by using cocos2d. I need a Picker. Is it possible to use Picker in cocos2d ! If possible then tell me, How can I use a Picker in cocos2d ?

                  推荐答案

                  是的,您可以将基于标准 UIView 的类与 Cocos2D 类混合搭配.

                  Yes, you can mix and match standard UIView based classes with Cocos2D classes.

                  在您的应用程序委托中,当您启动 Director 时,您创建了一个 UIWindow 并将 Director 附加到它.您还可以在 appdelegate 中保存对窗口的引用.现在您可以创建 UIViews 并将其添加到 Window,以及像往常一样通过 director 操作 cocos2d 节点.

                  In your application delegate, when you started up the Director, you created a UIWindow and attached the Director to it. You can also save a reference to the window in your appdelegate. Now you can create and add UIViews to the Window, as well as manipulate cocos2d nodes as usual through the director.

                  从这里开始,只需创建一个 UIPickerView 并将其添加到窗口中即可.配置 UIPickerView 本身就是一项完整的任务...... Nitrex88 有一个 关于该主题的精彩视频 .另外,请查看 UICatalog 以获得可靠的示例不仅是 UIPickerView,还有更多 UIView 子类.

                  From here, it's just a matter of creating a UIPickerView, and adding it to the window. Configuring the UIPickerView is a whole task unto itself... Nitrex88 has a good video on the subject . Also, check out UICatalog for a solid example not just of UIPickerView, but many many more UIView subclasses.

                  下面是一个向 cocos2d 应用添加一个简单的 UIPicker 的示例:

                  Here's an example of adding a trivial UIPicker to a cocos2d app:

                  #import <Foundation/Foundation.h>
                  #import <UIKit/UIKit.h>
                  #import "cocos2d.h"
                  
                  @interface AppDelegate {
                      UIWindow *window;
                      NSArray *pickerValues;
                  }
                  @property (nonatomic, retain) UIWindow window;
                  @property (nonatomic, retain) NSArray *pickerValues;
                  @end
                  
                  
                  @implementation AppDelegate
                  @synthesize window, pickerValues;
                  
                  -(void)applicationDidFinishLaunching:(UIApplication *)application {
                  
                      // Create Window
                      window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
                      [window setUserInteractionEnabled:YES];
                      [window setMultipleTouchEnabled:YES];
                  
                      // Set up Director and attach to window
                      [[Director sharedDirector] attachInWindow:window];
                      [[Director sharedDirector] setLandscape:YES];
                      [[Director sharedDirector] runWithScene:[MyScene node]];
                  
                      // Create one large view and rotate the coordinates to landscape
                      UIView *parentView = [[UIView alloc] initWithFrame:CGRectMake(0.0f,0.0f,480.0f, 320.0f)];
                      parentView.transform = CGAffineTransformIdentity;
                      parentView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
                      parentView.bounds = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);
                  
                      // Initialize picker and its data source
                      pickerValues = [[NSArray alloc] initWithObjects:@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",nil];
                      UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0f, 195.0f, 320.0f, 125.0f)];
                      [pickerView setDelegate:self];
                  
                      // Attach picker to parent view and parent view to window
                      [parentView addSubview:pickerView];
                      [window addSubview:parentView]; 
                      [window makeKeyAndVisible];
                  }
                  
                  - (void) dealloc {
                      [window release];
                      [pickerValues release];
                      [super dealloc];
                  }
                  
                  // ====================
                  // UIPicker Callbacks
                  // ====================
                  
                  // Fire when new picker values are selected
                  - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
                      NSString *numberSequence = [NSString stringWithFormat:@"Sequence: %@%@%@",
                                                  [pickerValues objectAtIndex:[thePickerView selectedRowInComponent:0]],
                                                  [pickerValues objectAtIndex:[thePickerView selectedRowInComponent:1]],
                                                  [pickerValues objectAtIndex:[thePickerView selectedRowInComponent:2]]];
                  
                      NSLog(numberSequence);
                  }
                  
                  
                  // Number of picker wheels in the picker
                  - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView                          {
                      return 3;
                  }
                  
                  // Number of items in each picker wheel
                  - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
                      return [pickerValues count];
                  }
                  
                  
                  // Title for Row #
                  - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
                      return [pickerValues objectAtIndex:row]; 
                  }
                  
                  
                  // Row height in pixels
                  - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
                      return 40.0;
                  }
                  
                  // Column width in pixels
                  - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
                      return 90.0f;
                  }
                  // ====================
                  
                  @end
                  

                  这篇关于在 cocos2d 中可以使用 UIPickerView 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)
                      <bdo id='A9GIq'></bdo><ul id='A9GIq'></ul>
                            <legend id='A9GIq'><style id='A9GIq'><dir id='A9GIq'><q id='A9GIq'></q></dir></style></legend>
                              <tbody id='A9GIq'></tbody>
                          • <small id='A9GIq'></small><noframes id='A9GIq'>

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