Search code examples
iosobjective-cios6uipickerview

disable CPPickerView not working


I'm making an iPhone/iPad app where I have PickerView. For PickerView, I am using CPPickerView.

I'm trying to disable this pickerview and to do that, I wrote this code:

[realEstatePV setUserInteractionEnabled:NO];

However, above is not working. I can still move the CPPickerView.

Any idea how to get this done?


Solution

  • I had the same problem. So i updated the CPPickerView, and its very easy.

    Open CPPickerView.h and add a method declaration

    - (void)enabled:(BOOL)val;
    

    Now open CPPickerView.mand add implementation method.

    -(void)enabled:(BOOL)val {
        self.contentView.scrollEnabled = val;
    }
    

    Its done......

    Now You can disable CPPickerView like this.

    [realEstatePV enabled:NO];
    

    To enable again use

    [realEstatePV enabled:YES];
    

    Hope this helps.