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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:09:03+00:00 2026-05-13T18:09:03+00:00

I have two UIPickerViews set up on one view under the same view controller.

  • 0

I have two UIPickerViews set up on one view under the same view controller. The picker’s seem to be populated with values as expected. I also have a label for each picker. The label updates with each value change, but the value displayed on the label is not correct. It’s always off by 10. The codes are below.

Interface:

#import <UIKit/UIKit.h>
#import "InfoViewController.h"



@interface TransactionsViewController : UIViewController {

    //Deposit
    NSMutableArray *depositArray;
    IBOutlet UIPickerView *depositPicker;
    IBOutlet UILabel *depositLabel;

    //Send
    NSMutableArray *sendArray;
    IBOutlet UIPickerView *sendPicker;
    IBOutlet UILabel *sendLabel;
}

@property (nonatomic, retain) NSMutableArray *depositArray;
@property (nonatomic, retain) IBOutlet UIPickerView *depositPicker;
@property (nonatomic, retain) NSMutableArray *sendArray;
@property (nonatomic, retain) IBOutlet UIPickerView *sendPicker;
@property (nonatomic, retain) IBOutlet UILabel *depositLabel;
@property (nonatomic, retain) IBOutlet UILabel *sendLabel;

@end

Implementation:

#import "TransactionsViewController.h"


@implementation TransactionsViewController
@synthesize depositArray;
@synthesize depositPicker;
@synthesize sendArray;
@synthesize sendPicker;
@synthesize depositLabel;
@synthesize sendLabel;


}



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];


    NSMutableArray *dollarsArray = [[NSMutableArray alloc] init];
    for (int i = 5; i <= 100; i+=5)
    {
        NSString *item = [[NSString alloc] initWithFormat:@"%i", i];
        [dollarsArray addObject:item];

        [item release];
    }

    self.depositArray = dollarsArray;
    self.sendArray = dollarsArray;

    [dollarsArray release]; 


}

// Pickers
#pragma mark - Pickers
#pragma mark Pickers Data Source Methods

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if(pickerView == depositPicker) {
    switch(component) {
        case 0:
            return 1;
            break;
        case 1:
            return [depositArray count];
            break;
        default:
            break;
    }
    }
    else if(pickerView == sendPicker) {
        switch(component) {
            case 0:
                return 1;
                break;
            case 1:
                return [sendArray count];
                break;
            default:
                break;
        }
    }
    return 0;
}

-(CGFloat)pickerView:(UIPickerView*)pickerView widthForComponent:(NSInteger)component {
    switch (component) {
        case 0:
            return 50;
            break;
        case 1:
            return 100;
            break;
        default:
            break;
    }
    return 0;
}

#pragma mark Pickers Delegate Methods

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if(pickerView == depositPicker) {
    switch(component) {
        case 0:
            return @"$";
            break;
        case 1:
            depositLabel.text=[depositArray objectAtIndex:row];
            return [depositArray objectAtIndex:row];
            [depositLabel release];
            break;
        default:
            break;
    }
    }
    else if(pickerView == sendPicker) {
        switch(component) {
            case 0:
                return @"$";
                break;
            case 1:
                return [sendArray objectAtIndex:row];
                break;
            default:
                break;
        }
    }
    return 0;
}

//Pickers End


- (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)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;

}


- (void)dealloc {
    [depositArray release];
    [send release];
    [super dealloc];

}


@end

Everything, such as the sendLabel, is not set up yet. As you can see, the depositLabel automatically updates with the selected row, however, the value is not updating to the correct value. I’m not sure if it’s my implementation of the label or the picker itself that is the problem.

I’d appreciate some inputs. Thanks.

  • 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-13T18:09:04+00:00Added an answer on May 13, 2026 at 6:09 pm

    The titleForRow method is just where you’re supposed to return the text for the row. In your titleForRow, it doesn’t make sense to set the label text there (nor do I think should you release it). The “return 0” at the end of titleForRow may also cause problems.

    To handle an actual select in a picker, use the didSelectRow method.

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

Sidebar

Ask A Question

Stats

  • Questions 316k
  • Answers 316k
  • 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 >>> is unsigned right shift, so I would think that… May 13, 2026 at 11:29 pm
  • Editorial Team
    Editorial Team added an answer The 'log_date_format' setting in config.php is the date format for… May 13, 2026 at 11:29 pm
  • Editorial Team
    Editorial Team added an answer You could teach them about stride notation (::) first and… May 13, 2026 at 11:29 pm

Related Questions

I'm programatically adding two custom UIPickerViews to another view (MainView). They work just fine
I have a UIPickerView. I'm customizing it's rows via it's delegate's viewForRow as follows:
Im doing an Iphone app with a UIPickerView. The picker view has two columns
I've got two controls on an iPhone screen - a TableView and a UIPickerView.
I have two applications written in Java that communicate with each other using XML

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.