Search code examples
objective-cuipickerviewxcode8

Do not allow to open UIPickerview in Objective C


Let me know if value is not available in UiPickerView, then do not allow to open UiPickerView?

How to handle this situation in objective C.

Thanks you, Shriram.


Solution

  • Check if

    [self.values count]>0
    

    then write

    yourPickerView.delegate=self;
    yourPickerView.datasource=self;
    

    If you don't call delegate and datasource then this method won't be called

    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [self.values count]; }