Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arnieterm

macrumors regular
Original poster
Aug 28, 2008
201
0
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!
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
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...
 

chbeer

macrumors member
Sep 22, 2008
82
0
Berlin
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.
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
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:

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];
[UIView setAnimationDuration:0.5];
self.transform = CGAffineTransformMakeTranslation(0, 100); // Offset.
[UIView commitAnimations];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.