Why isn't the UIPickerView widthForComponent delegate method called everytime the view appears?

前端 未结 3 1873
慢半拍i
慢半拍i 2021-01-25 08:19

I\'ve got two controls on an iPhone screen - a TableView and a UIPickerView. When you select the single cell in the TableView you\'re taken to another screen where you\'re show

3条回答
  •  悲&欢浪女
    2021-01-25 08:33

    It turns out that if you reset the picker's delegate, the component widths are redrawn each time a selection is made. The modified code looks like this:

    -(void)viewWillAppear:(BOOL)animated {
    
     ....
    
     self.PopulatePickerArray; // Populate components based on selection
    
     sizePicker.delegate = nil; // NEW CODE
     sizePicker.delegate = self; // NEW CODE
    
     [picker reloadAllComponents];
    
    }
    

    Found info on this web page - Changing-Width-UIPicker-Continually

提交回复
热议问题