Search code examples
iphoneuibuttonuipickerview

UIBUTTON and picker view


I want to display a picker when the user clicks on a button I subclassed the UIButton and changed its inputview so that it is writable.

I followed this link http://nomtek.com/tips-for-developers/working-with-pickers/

I clickon the button and nothing happens. If I change the inputview from the button to UITextField it works great. Any thoughts? Thanks Saro


Solution

  • The inputView property is only the part of UITextField and UITextView not UIButton.

       @property (readwrite, retain) UIView *inputView;
    

    Although you could achieve the same using UIButton.

    Create an UIButton object then set an action method and add your picker view in parent view of your button in the action method of UIButton.

    Should be something like that.

    -(void) buttonClicked:(id) sender
    {
        [self.view addSubview:myPickerView];
    }