Ok I am trying to connect a UIPickerView with a custom class. The idea is to have 3 picker views in one normal view.
- So far I have created one view and bound it to my class TestView.h
- Then I added a picker view to the view in the storyboard (iOS 5)
-
I then created a class for this picker view:
@interface TestPickerView : UIPickerView <UIPickerViewDelegate, UIPickerViewDataSource> { NSArray *data; } -
Then tried to add a Property to my normal view (TestView.h)
#import "TestPickerView.h" @interface TestView : UIViewController @property (strong, nonatomic) IBOutlet TestPickerView *myTestPicker; @end
But how do i bind the UIPickerView inside my normal view to this class/property?
I will in the end have 3 UIPickerView’s and my idea was to have 3 references in my UIViewController to control these UIPickerViews. That way I could set the data (datasource) using the properties once when the normal view is loading and then the PickerViews would just show. Hopefully i would also be able to get notified in my normal view when the value in one of the views occur.
Please call your
TestView>>TestViewControllerinstead, as it is a controller.In your storyboard, select the PickerView and change it’s class name to
TestPickerView.After that just create your three
IBOutletsand connect the PickerViews. That’s it.// edit: To explain, how you distinguish between the pickers. Make 3 outlets, e.g.:
And than in your delegate method, check which picker did call the delegate, e.g.: