Multiple UIPickerViews

前端 未结 1 1538
萌比男神i
萌比男神i 2020-12-21 17:01

I have a dilemma, I have two UIPickerViews which \"show\" when two distinct views load. I started with one UIPickerView and was able to get that up and running

1条回答
  •  没有蜡笔的小新
    2020-12-21 17:31

    Yeah you are, you have to use the UIPickerView argument to determine WHICH picker view is actually asking for data - since you have set both pickers to the same data source.

    -(void)numberOfComponentInPickerView:(UIPickerView*)thePickerView {
        if(thePickerView == firstPickerView) {
           // return number of components in first picker    
        } else if(thePickerView == secondPickerView) {    
           // return number of components in second picker    
        } else {
           assert(NO);
        }
    }
    
    // repeat for all other delegate / datasource methods
    

    0 讨论(0)
提交回复
热议问题