I am new to iOs and trying to add the picker UI element dynamically to the UI. In the class - UIPickerView , i don't see any methods for adding the picker to the view. Has anyone tried doing this? Thanks a lot.
A UIPickerView is a subclass of UIView, so you use the same methods that you'd use to add any subview to a view, namely
I'm assuming here that the code is in a view controller that's acting as both the delegate and data source for the picker. |
||||
|
First alloc memory to your picker view.
and then set delegate and datasource.
after that add picker view to your main view.
after that you should implement pickerview's method .
i hope this will work fine. |
|||
|
You adding the picker to the view just like and UIView you want to add -> addSubview method.
Don't forget to set it's delegate and implement it in order to achieve it's functionality. |
|||
|
As with other you need to alloc+initWithFrame.
Then add it to your target view.
Also you need to set it delegate and datasource, which will show all your elements in the picker view.
And all other customization as :
|
|||
|
[self.view addSubview:picker];
? There are several ways to integrate Picker to view. – Midhun MP Apr 23 at 5:36