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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:48:54+00:00 2026-06-04T22:48:54+00:00

I am having trouble with two UIPickerViews. The first picker named pickerParent selects a

  • 0

I am having trouble with two UIPickerViews.

The first picker named pickerParent selects a type of food.
The second picker named pickerChild then shows a list of those types of food.

The problem is if pickerChild tries to select one of those items, pickerChild then updates itself to match the corresponding item on the pickerParent’s list. (ex: if you select meat on pickerParent, pickerChild displays “Ginger Beef, Lemon Chicken, Salt & Pepper Ribs, and Sweet & Sour Pork”. If you then select Sweet & Sour Pork on the pickerChild List, being the fourth item on the list, it will then gain the attributes of Vegetables and only display “Assorted Vegetables”)

Can someone help me so pickerChild doen’t update itself?

my code is below.

#import "MasterViewController.h"

#import "DetailViewController.h"

@interface MainPage () {
   NSMutableArray *_objects;
}
@end

@implementation MainPage
@synthesize pickerChild;
@synthesize pickerParent;
@synthesize image_view;

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return ( pickerView == pickerParent ? 1 : 1 );
}

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    NSArray *values = ( pickerView == pickerParent ? topics : items );
    return [values count];
}

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    NSArray *values = ( pickerView == pickerParent ? topics : items );
    return [values objectAtIndex: row];
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    if ([[topics objectAtIndex:row] isEqual:@"Noodles"]) {
       items = noodle;
    } else if ([[topics objectAtIndex:row] isEqual:@"Rice"]) 
    {
       items = rice;
    } else if ([[topics objectAtIndex:row] isEqual:@"Meat"]) 
    {
        items = meat;
    } else if ([[topics objectAtIndex:row] isEqual:@"Vegetables"]) 
    {
        items = vegatable;
    } else if ([[topics objectAtIndex:row] isEqual:@"Favorites"]) 
    {
        items = favorite;
    }
[pickerChild reloadAllComponents];

}

- (void)awakeFromNib
{
    [super awakeFromNib];
}

- (void)viewDidLoad
{
    topics = [[NSMutableArray alloc] init];
    [topics addObject:@"Noodles"];
    [topics addObject:@"Rice"];
    [topics addObject:@"Meat"];
    [topics addObject:@"Vegetables"];
    [topics addObject:@"Favorites"];

    noodle = [[NSMutableArray alloc] init];
    [noodle addObject:@"Fried Noodles"];
    [noodle addObject:@"Shanghai Noodles"];

    meat = [[NSMutableArray alloc] init];
    [meat addObject:@"Ginger Beef"];
    [meat addObject:@"Lemon Chicken"];
    [meat addObject:@"Salt & Pepper Ribs"];
    [meat addObject:@"Sweet & Sour Pork"];

    vegatable = [[NSMutableArray alloc] init];
    [vegatable addObject:@"Assorted Vegetables"];

    rice = [[NSMutableArray alloc] init];
   [rice addObject:@"Fried Rice"];

    items = noodle;

    [super viewDidLoad];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}
@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-06-04T22:48:55+00:00Added an answer on June 4, 2026 at 10:48 pm

    Your didSelectRow.. delegate method doesn’t distinguish between the two pickers, so your child picker gets reloaded whichever picker you have changed. You only want to reload the child picker if the selection has changed in the parent picker.

    So, wrap the code you currently have in:

     if (pickerView == parentPicker)
    

    And you should be fine.

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

Sidebar

Related Questions

I'm having trouble removing the first two characters from my char array. input[MAXSIZE] =
I'm having trouble mapping two entities together with Entity Framework CTP5 using Code First
I'm new to linq and having trouble writing two simple queries. For some reason,
I am new to derived queries with MySQL and am having trouble with two
I am having some trouble comparing two variables, hope someone could help. Basically what
I am having trouble deciding between two possible design choices. I have a web
Im having some trouble with joining two tables. This is what my two tables
I am having some trouble with aligning two div boxes next to each other;.
I am having some trouble determining if two line segments are collinear because of
I'm having trouble with a simple radio set of two radio buttons (I don't

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.