Search code examples
objective-ciosipadinterface-builderuipickerview

UIPickerView property of another view not displaying even though I've set datasource, delegate


I have a FilterViewController that acts as a datasource and delegate for a UIPickerView I am displaying in a modal view. My pickerView is a property of a FilterActionSheetView which is in turn a property of a FilterActionSheetViewController.

My code is as follows:

    UIPickerView *pickerView = self.customASVC.actionSheetView.pickerView;

    pickerView.delegate = self;
    pickerView.dataSource = self;

    NSLog(@"%@,pickerView);

    [self.tabBarController.view addSubview:self.customASVC.view];
    [self.customASVC viewWillAppear:NO];

However the result of the NSLog() is always nil and thus my picker view never shows up, even as an empty picker view. My impression was that as long as I set the pickerView's datasource and delegate appropriately it would show up.


Solution

  • customASVC or actionSheetView or pickerView (the pickerView that's a property of actionSheetView) is nil. Break that chain up into separate statements and see where you're getting a nil value.