Search code examples
iosxcodeuipickerview

UIPickerView varying row number - iOS


I have a UIPickerView which will be loaded with two different data sets based on which button the user presses. One array has a count of 10 and another 6. Is it possible to fill in the same picker view with these two datas? I end up in an error when I load up with array with count of 6 when I have set the numberOfRow method to return 10. Any ways to overcome this?


Solution

  • Within the UIpickerview delegates have some sort of if statement to reflect the changes

    if(button1 pressed){
    return array
    }
    else{ return array 2}
    

    Do the same for number of rows and datasource callbacks