I want to know how can i make a generic/single UIPickerView
to display in multiple ViewControllers
.
I want to show a pickerView in multiple ViewController. Now how can i create it.
I know how to create it like implement and write its delegate for it..
But i don't want to create these delegate in each class and write those method again and agian..
What have i done..
I have created a new File and inherit it with UIPickerView
. and create an NSArray property
to show in it. and also implemented its delegate but now onward don't know how to do it .
Show me some sort of example to make a generic UIPickerView or help me creating it..
One way to do this would be to create a class with a completion handler that creates the picker and acts as its data source and delegate. For example, in the .h file, you could do something like this,
In the .m file, implement any of the data source and delegate methods that you need, and call the completion block in the pickerView:didSelectRow:inComponent: method,
In your controller classes, you can create and use the picker like this,