2
我使用的this code「模擬」下拉菜單,因爲它在html代碼中工作。我在頁面上添加了2個下拉菜單。當我在第一個下拉菜單中選擇一個項目時,需要通知我的控制器,並且需要在此通知中提供選定下拉項目中的選定ID。如何在第一個下拉列表中選擇一個項目時通知我的控制器?還有,我如何在第一個下拉列表中打包所選標識的通知?如何通知控制器需要更新
我初始化用下面的代碼下拉:
ddDuration = [[UIDropDownMenu alloc] init];
[ddDuration makeMenu:txtDurationId titleArray:arrDurationIds valueArray: arrDurationNames targetView:self.view];
[ddDuration setDropdownTextColor:[UIColor whiteColor]];
[ddDuration setDropdownBackgroundColor:[UIColor darkGrayColor]];
的arrDurationsId
和arrDurationNames
包含相同數目的元素。第一個包含ID和後者的名稱。
然後,我希望下面的方法在dropdown 1
中被選中時調用。發件人需要包含來自dropdown 1
的選定項目ID - 以便dropdown 2
知道應將哪些內容加載到該項目中。
- (IBAction)didSelectCountry:(id)sender {
[ddDestination makeMenu:txtDestinationId titleArray:arrDepartureIds valueArray: arrDepartureNames targetView:self.view];
[ddDestination setDropdownTextColor:[UIColor whiteColor]];
[ddDestination setDropdownBackgroundColor:[UIColor darkGrayColor]];
}
所以基本上你想在被選擇的對象,並從菜單就知道..? –