Hey I have a view that has a button that when pressed should modally present a UIDatePicker
. I have the picker showing up properly, but because it is on its own UIView
, it is full height, and looks funny. All I want is to get a really quick date input from the user, more like a UIActionSheet
than a UIView
.
How can I make the UIPicker
slide up modally only halfway and have some actions on a toolbar, like done etc?
Thanks
You could put it on another UIView which has a transparent background, or more simply, don't use presentModalViewController, but write your own routine to show it in the current view.
// Untested code:
// put this in your current UIViewController (the one where you were going to call presentModalViewController:)
- (void)showPicker:(UIPickerView *) picker{
CGRect startFrame = picker.frame;
CGRect endFrame = picker.frame;
// Set the start position to below the bottom of the visible frame:
startFrame.origin.y = self.view.frame.size.height;
// Set the end position to slid up by the height of the view, so it will just fit:
endFrame.origin.y = startFrame.origin.y - endFrame.size.height;
picker.frame = startFrame;
[self.view addSubView:picker];
[UIView beginAnimations]
picker.frame = endFrame;
[UIView commitAnimations];
}
You would of course need to add all the necessary code to keep a pointer to the picker and keep track of when to show and get rid of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With