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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:22:40+00:00 2026-06-09T02:22:40+00:00

I have two pickers in a singe view controller. They use two NSArray for

  • 0

I have two pickers in a singe view controller. They use two NSArray for their data.

The problem is that for both pickers, when the titleForRow method is called, the value of the component parameter is always zero, hence all the rows display the first string from their data arrays.

Why is this happening and how do i fix it?

These are my delegate methods:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    NSLog(@"%d",[pickerView tag]);
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:    (NSInteger)component
{
    NSLog(@"%d",[pickerView tag]);
    if ([pickerView tag] == 0)
        return providersList.count;
    else
        return amountList.count;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    NSLog(@"%d, %d",[pickerView tag],component);
    if ([pickerView tag] == 0)
        return [providersList objectAtIndex:component];
    else
        if ([pickerView tag] == 1)
            return [amountList objectAtIndex:component];
        else
            return nil;
}

Using xcode 4.3 and iOS5.

  • 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-09T02:22:41+00:00Added an answer on June 9, 2026 at 2:22 am

    Component is used for number of sections in picker and row is used for a particular row in component. When your picker is having multiple sections, you will receive different values for component. Row is indicating the Row in component.

    So, if you have only one component then you should use row.

    [amountList objectAtIndex:row];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok here is my problem. I have a view that loads another view as
I have two overlay images that I want show in camera view depending on
I have two UIPickerViews set up on one view under the same view controller.
I've got two date pickers in one form. They have different id's so this
I have a table view that has embedded UITextFields for entering some data. It
I have two datetime pickers that I'm using to set a start and end
I have picker controls on a single view with two outlets for each. When
I have two date pickers one for startDate and another one is for endDate.
HI i have two date pickers. datepicker1, datepicker2. I need datepicker1.date to compare with
I have two classes (MVC view model) which inherits from one abstract base 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.