0

如何UIPickerView在不使用 Interface Builder 的情况下以编程方式设置视图?UIPickerView 当我从第一个UIPickerView,第二个UIPickerView 更改这些值中选择一个值时,也无法理解如何做两个?第一个UIPickerView 国家和第二个UIPickerView 城市。

4

2 回答 2

0
Yes possible you can create array on city within country like
int select=0;

(
   india
       (
         city,
         .....,
       )
   Australia
       (
         City,
         ......,
    )
)

and use
picker

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
   if(picker==1)
   {
     return [arr_counry count];
   }
   else if(picker==2)
   {
     return [[arr_counry objectAtIndex:select] count];
   }

}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
  if(picker==1)
   {
     select=[arr_currency objectAtIndex:row];
    [picker reloadAllComponents];

   }
   else if(picker==2)
   {

   }
}
于 2013-06-27T05:38:37.873 回答