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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:14:31+00:00 2026-05-25T13:14:31+00:00

I am working on a UIPickerController. I have everything working but when I tap

  • 0

I am working on a UIPickerController. I have everything working but when I tap the back button to go to my previous view the app is crashing.

I am thinking it could be catching a memory leak.

Here is my code. If anyone sees something I have missed or may have a clue on what cause this please inform me. Nothing displays in the Debugger.

@synthesize colorTextField, pickerView, pickerToolbar;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [colorTextField release];
    [pickerView release];
    [pickerToolbar release];
    [super dealloc];

}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}


- (void)viewDidLoad
{
    [super viewDidLoad];

    colorsArray = [[NSMutableArray alloc] init];
    [colorsArray addObject:@"Red"];
    [colorsArray addObject:@"Orange"];
    [colorsArray addObject:@"Yellow"];
    [colorsArray addObject:@"Green"];
    [colorsArray addObject:@"Blue"];
    [colorsArray addObject:@"Indigo"];
    [colorsArray addObject:@"Violet"];
}

- (void)setColor
{    
     actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];   

     [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

     CGRect pickerFrame = CGRectMake(0, 40, 0, 0);  
     pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];  
     pickerView.showsSelectionIndicator = YES;  
     pickerView.dataSource = self;  
     pickerView.delegate = self;  

     [actionSheet addSubview:pickerView];
     [pickerView release];

     pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, actionSheet.bounds.size.width, 44)];
    [pickerToolbar setBarStyle:UIBarStyleBlack];
    [pickerToolbar sizeToFit];

    UIBarButtonItem* doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(pickerDoneClicked)];

     [pickerToolbar setItems:[NSArray arrayWithObject:doneButton] animated:NO];
     [doneButton release];

     [actionSheet addSubview:pickerToolbar];
     [pickerToolbar release];

     [actionSheet showInView:self.view];

     [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];  
}

- (void)pickerDoneClicked
{    
   [actionSheet dismissWithClickedButtonIndex:0 animated:YES];
    [actionSheet release];
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    [self setColor];
    return NO;
}


- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {

     return 1;
 }

 - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
 {
     return [colorsArray count];
 }

 - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    return [colorsArray objectAtIndex:row];
 }

 - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

     NSLog(@"Selected Color: %@. Index of selected color: %i", [colorsArray objectAtIndex:row], row);
    [colorTextField setText:(NSString *)[colorsArray objectAtIndex:row]];
}

- (void)viewDidUnload
{
    [self setColorTextField:nil];
    [super viewDidUnload];
}

 - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
 {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

 @end
  • 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-25T13:14:31+00:00Added an answer on May 25, 2026 at 1:14 pm

    I think your release some of your items mor ethan once
    EG:

    in the dealloc you have two
    [pickerView release];
    [pickerToolbar release];

    that are release already
    eg:
    [actionSheet addSubview:pickerView];
    [pickerView release];

    so it has nothing to release me thinks, so remove the duplicate releases??

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

Sidebar

Related Questions

Working on an image gallery, but it keeps crashing on me (you control it
Working on my first Android app here. I've searched and tried everything I can
Working on a project at the moment and we have to implement soft deletion
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
Working on a .NET app, I've run in a 'cross-thread operation not valid' exception,
Working in the JBoss AS portlet we have been unable to open a jsp
Working in Xcode on Mac OS X Leopard in C++: I have the following
Working on a Online Test. I have 3 tables Questions Subject Topic I have
Working with some basic java apps on CentOS 5 linux and I have my
Working with jquery.ajax for first time... I have a class in C#: public class

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.