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 6157937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:52:10+00:00 2026-05-23T20:52:10+00:00

I have a CCLayer which I need to add a camera to, on top

  • 0

I have a CCLayer which I need to add a camera to, on top of that I need a custom button to close the camera overlayed onto of the camera. I eventually need to display CCSprites on top of it all, but first need to be able to dismiss the camera.

But when I click on the button, I get SIGABRT or BAD EXE errors depending on whether I use [[[CCDirector sharedDirector] openGLView] sendSubviewToBack:uip.view]; or [uip.view removeFromSuperview];

-(void) displayCamera
{

uip = [[[UIImagePickerController alloc] init] autorelease];
uip.sourceType = UIImagePickerControllerSourceTypeCamera;
uip.showsCameraControls = NO;
uip.toolbarHidden = YES;
uip.navigationBarHidden = YES;
uip.wantsFullScreenLayout = YES;

[[[CCDirector sharedDirector] openGLView] addSubview:uip.view];

UIButton *arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
[arrowButton addTarget:self 
           action:@selector(arrowButtonClicked:)
 forControlEvents:UIControlEventTouchUpInside];

UIImage *imgNormal = [UIImage imageNamed:@"btn_next_norm.png"];
[arrowButton setImage:imgNormal forState:UIControlStateNormal];

UIImage *imgPressed = [UIImage imageNamed:@"btn_next_pressed.png"];
[arrowButton setImage:imgPressed forState:UIControlStateHighlighted];

arrowButton.frame = CGRectMake(screenSize.width - 48.0, screenSize.height - 37.0, 48.0, 37.0);

[[[CCDirector sharedDirector] openGLView] addSubview:arrowButton];
}

-(void)arrowButtonClicked:(id)sender
{
 // close / hide camera 

[[[CCDirector sharedDirector] openGLView] sendSubviewToBack:uip.view];

// or maybe [uip.view removeFromSuperview];

// and then go to another scene

LoadingScene* scene = [LoadingScene sceneWithTargetScene:TargetSceneEndExperienceScene];
[[CCDirector sharedDirector] replaceScene:scene];    
}
  • 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-23T20:52:11+00:00Added an answer on May 23, 2026 at 8:52 pm

    I believe the issue is this line:

    uip = [[[UIImagePickerController alloc] init] autorelease];
    

    Using autorelease in this case doesn’t work because the UIImagePickerController is not retained by it’s view, so you need to make sure that you retain it yourself. Instead of autoreleasing it, I would hold onto the reference to it, and then after you remove it from the view, I would release it then. I’ve changed your code to show what I mean:

    -(void) displayCamera
    {
    
    uip = [[UIImagePickerController alloc] init];  // Don't autorelease it here
    uip.sourceType = UIImagePickerControllerSourceTypeCamera;
    uip.showsCameraControls = NO;
    uip.toolbarHidden = YES;
    uip.navigationBarHidden = YES;
    uip.wantsFullScreenLayout = YES;
    
    [[[CCDirector sharedDirector] openGLView] addSubview:uip.view];
    
    UIButton *arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [arrowButton addTarget:self 
               action:@selector(arrowButtonClicked:)
     forControlEvents:UIControlEventTouchUpInside];
    
    UIImage *imgNormal = [UIImage imageNamed:@"btn_next_norm.png"];
    [arrowButton setImage:imgNormal forState:UIControlStateNormal];
    
    UIImage *imgPressed = [UIImage imageNamed:@"btn_next_pressed.png"];
    [arrowButton setImage:imgPressed forState:UIControlStateHighlighted];
    
    arrowButton.frame = CGRectMake(screenSize.width - 48.0, screenSize.height - 37.0, 48.0, 37.0);
    
    [[[CCDirector sharedDirector] openGLView] addSubview:arrowButton];
    }
    
    -(void)arrowButtonClicked:(id)sender
    {
     // close / hide camera 
    
    [uip.view removeFromSuperview];
    [uip release];  // Release here
    uip = nil;
    
    // and then go to another scene
    
    LoadingScene* scene = [LoadingScene sceneWithTargetScene:TargetSceneEndExperienceScene];
    [[CCDirector sharedDirector] replaceScene:scene];    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a CCLayer class on top of which i am adding another CClayer
I have a CALayer which I merely create and add to a subview of
I am have a custom CALayer which should look different with respect to different
Alright lets say I have a cPlayer class that inherits from cOrganism , which
I have a UIScrollView which contains any number of thumbnails that should detect the
I have a CCLayer class where I create an animated sprite that is the
I have to add one slider in CCLayer. How to make slider. I went
I have written a custom class that depends significantly on touch dragging/positioning, outside of
I have this function return [remoteObject objectForKey:key]; which should return an object that is
I have a CALayer with some image contents. When a button touched, I want

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.