views:

3865

answers:

3

I am looking for a way to slide a UIPickerView (and UIDatePickerView) up over a view (UITableView in particular) when a particular button press takes place.

I understand how to get the events for clicks into the UITableView, but there doesn't seem to be a good way to have the UIPickerView slide up on top of it...

All the examples I have seen so far just have it snapped to the bottom of another view and I am able to do this without issue.

Thoughts?

Thanks in advance.

+1  A: 

Have you tried using UIView's animation blocks do do this? See the Apple docs on +[UIView beginAnimations:context:] and +[UIView commitAnimations]. Basically, wrap your calls to display the UIPickerView in these calls, and you can slow it down a bit.

Ben Gottlieb
+3  A: 

Modally presented view controllers slide up from the bottom to cover the current view.

See the documentation for -presentModalViewController:animated: in the UIViewController Class Reference. You would invoke this method on your UITableViewController and pass the UIPickerViewController as the first parameter and YES as the second.

Matt Gallagher
+1  A: 

An example of what Ben mentions above (Animation Blocks) is the following, which will animate to a subview.

UIWindow *window = [[Director sharedDirector] window];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:(UIViewAnimationTransitionCurlDown)
        forView:window
       cache:YES];
[window addSubview:aView];
[UIView commitAnimations];
Brad Parks