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]];
}
You has the solution in the same page from where you download the code. Check this
and this