tags:

views:

110

answers:

2

Hi,

How I could able to add a toolbar to the picker? I want above the picker there is a toolbar with a "done" bar button item. clicking the "done" button will hide (animate) the picker offscreen (going to bottom like the keyboard)

I'm still looking for this how-to... Hope you could help me.

Thanks

A: 

The easiest way would be to make a new UIToolbar and position that directly above your picker view when you animate it in. Check out the DateCell example for animation code.

Jeff Kelley
+1  A: 

When I need to do this, I typically make a container view and place into it both the picker and the toolbar. This allows the grouping to be hidden, moved, sized, etc as a unit.

UIView *pickerGroupView = [[[UIView alloc] initWithFrame: frame] autorelease];
thePicker.frame = pickerGroupView.bounds;
[pickerGroupView addSubview: thePicker];

theToolbar.center = pickerGroupView.center;  // assuming that's where you want it
[pickerGroupView addSubView: theToolbar];
Olie
Olie, i've tried your suggestion..but seems the picker and the toolbar (above the picker) is not aligned properly.. see the screenshots (http://img171.imageshack.us/img171/4043/screenshot20100608at450.png)hope you can check my code (http://pastebin.com/XJZG9RWH)
devb0yax