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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:50:18+00:00 2026-06-13T15:50:18+00:00

I am using this code that simulates a dropdown menu as it works in

  • 0

I am using this code that “simulates” a dropdown menu as it works in html code. I have added 2 dropdown menus on my page. When I select an item in the first dropdown menu then my controller needs to be notified and the selected id from the selected dropdown item needs to be given in this notification. How can I notify my controller whenever an item has been selected in the first dropdown ? And also how do I package the notication with the selected id from the first dropdown list?

I initialize a dropdown using the below code:

ddDuration = [[UIDropDownMenu alloc] init];
[ddDuration makeMenu:txtDurationId titleArray:arrDurationIds valueArray: arrDurationNames targetView:self.view];
[ddDuration setDropdownTextColor:[UIColor whiteColor]];
[ddDuration setDropdownBackgroundColor:[UIColor darkGrayColor]];

The arrDurationsId and arrDurationNames contains the same number of elements. The first contains the ids and the latter the names.

Then I want the method below to be called whenever an item gets selected in dropdown 1. The sender needs to contain the selected item id from dropdown 1 – in order for dropdown 2 to know which content should be loaded into it.

- (IBAction)didSelectCountry:(id)sender {
    [ddDestination makeMenu:txtDestinationId titleArray:arrDepartureIds valueArray: arrDepartureNames targetView:self.view];
    [ddDestination setDropdownTextColor:[UIColor whiteColor]];
    [ddDestination setDropdownBackgroundColor:[UIColor darkGrayColor]];
}
  • 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-13T15:50:20+00:00Added an answer on June 13, 2026 at 3:50 pm

    You has the solution in the same page from where you download the code. Check this

    [menu1 addObserver:self forKeyPath:@"selectedValue" options:NSKeyValueObservingOptionNew context:@"menu1"];
    

    and this

    -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change (NSDictionary *)change context:(NSString *)context
    {
        // get the selected menu and value
        NSString* changedObject = context;
        NSString* changedValue = [change objectForKey:NSKeyValueChangeNewKey];
    
        NSLog(@"%@ has changed to %@", changedObject, changedValue);
    
        // Menu 1 selected
        if ([context isEqualToString:@"menu1"]){
            // create a new array for menu 2.  
            NSArray *arrayNames2 = [[NSArray alloc] initWithObjects:
                            @"Erik Vanderwal",
                            @"Max Town",  
                            @"Avis Villalon",
                            @"Hugh Salvia",
                            nil];
    
            // rebuild menu 2 with the new array values
            [menu2 makeMenu:textfield2 titleArray:arrayNames2 valueArray: arrayNames2 targetView:self.view];
    
            // run makemenu with nil array values to clear the old values from menu 3
            [menu3 makeMenu:textfield3 titleArray:nil valueArray: nil targetView:self.view];
    
        }
    
        // Menu 2 selected
        if ([context isEqualToString:@"menu2"]){
            NSArray *arrayNames3 = [[NSArray alloc] initWithObjects:
                                @"Erik Vanderwal",
                                @"Hugh Salvia",
                                nil];
    
            [menu3 makeMenu:textfield3 titleArray:arrayNames3 valueArray: arrayNames3 targetView:self.view];
    
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that fetches some text from a page using BeautifulSoup soup=
I have create a vcf file that contains contacts by using this code ContentResolver
I have a code that looks like this: using (DC dc = new DC())
I'm makin' a scripting language interpreter using PHP. I have this code in that
I am using this code to check that array is present in the HashMap
Ok, I've got this code that I've been using to spit out news to
I've recently been working with code that looks like this: using namespace std; class
This is the code that I'm using to generate a DH keypair: KeyPairGenerator keyGen
This is the code that I am using for an HTTP connection: HttpConnection connection
I'm using a code that looks like that: img.load(function(){ // do some stuff $(this).width();

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.