Hi I am develop开发者_运维技巧ing an iPhone app which uses pickerview, Upon shaking app selects one random choice. Everything works well but I was wondering is there any way to animate the UIPIckerView as Urban Spoon has done it.
Confession time: when I posted the other answer, I hadn't ever used Urban Spoon, and I assumed you were being lazy. I'm not overwriting my earlier answer, because such a rude response deserves the downvotes it got.
If I were going to make an animation like the ones on urban spoon's picker wheels, I'd probably use UIImageView's flipbook-style animation, as demonstrated here: http://iosdevelopertips.com/graphics/animated-gif-animated-images-iphone-style.html
Short version: the property UIImageView.animationImages
can be loaded with an NSArray of UIImages. You can set properties like .animationRepeatCount
and .animationDuration
. And then [UIImageView startAnimating]
will make that thing start animating.
I'd guess Urban Spoon does that for a second with the "fast rolling" set of images, replaces that with the "medium-speed rolling" set of images, and then gets rid of the UIImageView entirely and replaces it with a UIPickerView that's animating its way to a pre-selected random position.
The method you want is
- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated
All else fails, you could always try looking at the docs. http://developer.apple.com/iphone/library/documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html
精彩评论