views:

75

answers:

1

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

A: 

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.

 //un tested 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;
      startFrame.origin.y = self.view.frame.size.height;   //now the start position is below the bottom of the visible frame
      endFrame.origin.y = startFrame.origin.y - endFrame.size.height;    //now the end position is slid up by the height of the view, so it will just fit.
      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.

Alex Gosselin
Perfect! Thats just what I needed
Jerry