View Full Version : Pop up of UIPickerView
Feb 16, 2009, 04:40 AM
Hi, this is what I am trying to do. I currently have a UIPickerView added to a subview on in my ViewController class. What I want to do to is to load this subview on the tap of UITextField and have it animate up instead of just magically pop out of nowhere.
I want this subview to animate from the bottom to the middle of the screen like that of a keyboard. Any help/pointers would be much appreciated and thanks in advance!
Feb 16, 2009, 04:54 AM
I've done this, it's not too hard - I just subclassed UIPickerView with some extra methods to scroll it up when it was made visible. Getting the animation to work right is the hardest bit. The one thing to think about is that a Picker View doesn't have a return key or any way to dismiss it when the user is finished...
Feb 16, 2009, 05:35 AM
I have done this already, too. You should add a Toobar or something like that above/below the UIPicker. The animation is rather easy using UIViews beginAnimation/commitAnimation. The trick is to set the y-position below the screen first and then set it to the middle in the animation-block.
Feb 16, 2009, 06:51 AM
The animation is rather easy using UIViews beginAnimation/commitAnimation. The trick is to set the y-position below the screen first and then set it to the middle in the animation-block.
Just to put this (roughly) into code:
CGRect rect = yourPicker.frame;
CGPoint origin = CGPointMake(0, -100); // Some off-screen y-offset here.
rect.origin = origin;
yourPicker.frame = rect;
// Perform transform to slide it onto the screen.
[UIView beginAnimations:nil context:NULL];
self.transform = CGAffineTransformMakeTranslation(0, 100); // Offset.