我想在ui选择器视图中使用第一个组件的日期



我正试图在第一个组件的选择器视图中使用日期。我想将另一个组件与另一个数组一起使用。

请帮帮我。。。感谢

您将需要2个数组,对吗?然后声明并填充要在两个组件中使用的两个数组,如下所示:

NSArray *firstComponentArray = // populate the first array here
NSArray *secondComponetArray = // populate the second array here
.
.
.
- (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
   // return the number of components do you need
}
// return the right number of items in picker view delegate: numberOfRowsInComponent
- (NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent(NSInteger)component
{   
   // first component
   if ( component == 0 )
     // return the count of the first array
   // second component  
   else
     //return the count of the second array
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row   forComponent:(NSInteger)component
{
   // first component
   if ( component == 0 )
     // return the content of the first array at index using row

   // second component  
   else
     // return the content of the second array at index using row
}

最新更新