2014-09-07 4 views

답변

0

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 
} 
관련 문제