My application requires following things to be added in an action sheet.
- UIToolbar
- Button on UIToolbar
- UIPicker Control
I have included an image to understand my requirements.
Could you please explain, how this can be implemented?
My application requires following things to be added in an action sheet.
I have included an image to understand my requirements.
Could you please explain, how this can be implemented?
One more solution:
no toolbar but a segmented control (eyecandy)
Marcio's excellent solution to this question was of great help to me in adding subviews of any kind to a UIActionSheet.
For reasons that are not (yet) entirely clear to me, the bounds of the UIActionSheet can only be set after it has been displayed; both sagar's and marcio's solutions successfully address this with a setBounds:CGRectMake(...) message being sent to the actionsheet after it is shown.
However, setting the UIActionSheet bounds after the sheet has been displayed creates a jumpy transition when the ActionSheet appeaars, where it "pops" into view, and then only scrolls in over the final 40 pixels or so.
When sizing a UIPickerView after adding subviews, I recommend wrapping the setBounds message sent to the actionSheet inside an animation block. This will make the entrance of the actionSheet appear smoother.
I liked the approach taken by Wayfarer and flexaddicted, but found (like aZtral) that it did not work as the backgroundTapButton was the only element that was responding to user interaction. This led me to put all three of his subviews: _picker, _pickerToolbar and backgroundTapButton inside a containing view (popup) which was then animated on and off the screen. I also needed a Cancel button on the _pickerToolbar. Here are the relevant code elements for the popup view (you need to supply your own picker data source and delegate methods).
Even though this question is old, I'll quickly mention that I've thrown together an ActionSheetPicker class with a convenience function, so you can spawn an ActionSheet with a UIPickerView in one line. It's based on code from answers to this question.
Edit: It now also supports the use of a DatePicker and DistancePicker.
UPD:
This version is deprecated: use ActionSheetPicker-3.0 instead.
I think this is best way to do it.
ActionSheetPicker-3.0
Its pretty much what everyone suggest, but uses blocks, which is a nice touch!
Yep ! I finally Find it.
implement following code on your button click event, to pop up action sheet as given in the image of question.