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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:40:29+00:00 2026-06-04T12:40:29+00:00

I have two columns pickerView. In first column i have units like km, feet.

  • 0

I have two columns pickerView. In first column i have units like km, feet. I want to set different values for both like km 1,2,3 and for feet 100, 2000, 300. Now I did following code. I declare two arrays unitArray and distanceArray in viewDidLoad method.

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

-(NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{

if (component == UNIT)
       return [unitArray objectAtIndex:row];
else
       return [distanceArray objectAtIndex:row];
}

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

        distanceRow = [distancePicker selectedRowInComponent:DISTANCE];
        unitRow = [distancePicker selectedRowInComponent:UNIT];

        dist = [distanceArray objectAtIndex:distanceRow];
        unit = [unitArray objectAtIndex:unitRow];

        txtIBOutletDistance.text =[NSString stringWithFormat:@"%@ %@",dist,unit];
}

After doing this code i am showing same values for both km and feet i.e km and feet in one column and 1,2,3 in second column. I want after selecting km values should be 1,2,3 and for feet selection values should be 100,200,300. If any one knows how to do it please help me. I will appreciate him/her.

  • 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-04T12:40:31+00:00Added an answer on June 4, 2026 at 12:40 pm

    You should change the value of distanceArray in pickerView:didSelectRow:inComponent according to the selected UNIT as below:

    - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
        if(component == UNIT) {
            unit = [unitArray objectAtIndex:row]; //unit is a property of the interface
            if([unit IsEqualToString:@"km"] {
                distanceArray = [NSArray arrayWithObject:@"1", @"2", @"3", nil];
            } else if([unit IsEqualToString:@"feet"] {
                distanceArray = [NSArray arrayWithObject:@"100", @"200", @"300", nil];
            }
        } else {
            dist = [distanceArray objectAtIndex:row];
            txtIBOutletDistance.text =[NSString stringWithFormat:@"%@ %@",dist,unit]; 
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two columns. Column E extends up to 99504 (values) and column I
I have two columns of numbers. Both are 1 to 5. I want to
I have two columns (both primary) [PLAYER_ID] [LEAUGE_ID] something like this: Player_id League_id 2139
I have two columns, the first column will have the name of a object,
I have two columns with two values.. I want to append some text to
I have UIPickerView with two columns and in one column I want to display
I have two columns. The column on the left renders first (obviously). The column
I have two columns. People have to select elements from the first column and
I have two columns in Excel. In the first column I have a master
I have two columns and want to stack divs of different heights in order

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.