Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 236519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:21:06+00:00 2026-05-11T20:21:06+00:00

I am developing iPhone 2d game by using cocos2d. I need a Picker. Is

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:21:06+00:00Added an answer on May 11, 2026 at 8:21 pm

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

    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.

    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.

    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's fundamentally impossible to predict at compile time what will… May 12, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer It honestly depends on the site. If it's the type… May 12, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer window.onload = function() { var txts = document.getElementsByTagName('TEXTAREA'); for(var i… May 12, 2026 at 12:48 am

Related Questions

I am developing a 2D iPhone game by using cocos2d. I need a countdown
I am developing a 2d game for iPhone by using cocos2d. I use many
I'm developing a 2D game for the iPhone using OpenGL ES and I'd like
I am developing iPhone application and In that application I've one TableViewController , and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.