开发者

Animating UIPickerView

开发者 https://www.devze.com 2023-01-05 13:59 出处:网络
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 UIPIckerVie

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

0

精彩评论

暂无评论...
验证码 换一张
取 消