UIPickerView not showing

I have a UIPickerView on a UIView. I implemented my protocol in .h and delegates in .m files:

<UIPickerViewDataSource, UIPickerViewDelegate> 

In IB, I connected this to a collector, for which I also have an IBoutlet. The methods look like this:

 - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { return 1; } - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { return [self.arr count]; } - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return @"test"; } - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { //do something } 

Any ideas that I'm missing to get the collector to work?

+4
source share
3 answers

If the delegate methods are not called, then in IB double-check that the delegate of the collector view and data sources are connected to the file owner.

In the .h file, the output point of the selector must be declared as follows:

@property (non-atomic, save) IBOutlet UIPickerView * pickerView;

+7
source

you did not assign a delegate to the UIPickerView, so the reason why none of the delegate methods are called.

  UIPickerView *pickerView; pickerView.delegate = self;//write this line in view did load method. 

Hope this helps and let me know if this answers your question .. :)

+3
source

sometimes this is because pickerview is not connected to the Owner Owner data source file and delegate to nib

+1
source

Source: https://habr.com/ru/post/1308615/


All Articles