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

  • Home
  • SEARCH
  • 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 9078275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:34:45+00:00 2026-06-16T19:34:45+00:00

I am using a UISwitch in my cocos2d project like so: //header file UISwitch

  • 0

I am using a UISwitch in my cocos2d project like so:

//header file

UISwitch    *musicCtrl;

//implementation file


        musicCtrl = [[UISwitch alloc] initWithFrame:CGRectMake(100, 50, 0, 0)];
        musicCtrl.on = YES;
        [musicCtrl addTarget:self action:@selector(musicOnOff) forControlEvents:UIControlEventValueChanged];
        [[[CCDirector sharedDirector]openGLView] addSubview:musicCtrl];
        musicCtrl.transform = CGAffineTransformMakeRotation(M_PI/2);
        [musicCtrl release];

I have attached the UISwitch to the openGLView but I need to be able to attach it to a certain CCLayer on the GLView. Is that possible? I can’t seem to find a UISwitch alternative for 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-06-16T19:34:47+00:00Added an answer on June 16, 2026 at 7:34 pm

    It’s not possible.

    You can only add UIKit views to the cocos2d view, or the main window. Either way, the UIKit view will be drawn above all of the cocos2d nodes. You can not add a UIKit view to a specific layer.

    Specifically you can’t add UIKit views to a cocos2d app in a way where some cocos2d nodes are drawn in front of and other nodes drawn behind the UIKit view. That is impossible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my app asks the user yes-no questions, user replies using a uiswitch on screen.
I am using a UISwitch in in the menu of a Cocos2d game I
I'm using DCRoundSwitch for a project where I basically need an UISwitch where I'm
I'm using a UISwitch-Component at the bottom of a view that sits within a
Using ASIHTTPRequest, I downloaded a zip file containing a folder with several audio files.
How can I add UISwitch(toggle switch) to UIToolBar without using InterfaceBuilder ? It is
I am using UISwitch in iOS 3 to make a switch element in my
Using this code, the following execution yields strange results: C 100 R W The
using grep, vim's grep, or another unix shell command, I'd like to find the
I am using a UISwitch in the ViewController, it displays as ON and OFF,

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.