开发者

iphone UIPicker default position

开发者 https://www.devze.com 2023-01-04 04:46 出处:网络
Is there a way t开发者_C百科o set a default position for a UIPicker?I mean, if the user has the option of selecting any number from 1 to 100 in the UIPicker, can I set it to automatically start at 50?

Is there a way t开发者_C百科o set a default position for a UIPicker? I mean, if the user has the option of selecting any number from 1 to 100 in the UIPicker, can I set it to automatically start at 50?


You can use selectRow:inComponent:animated: like this:

[somePickerView selectRow:49 inComponent:0 animated:NO]; // Zero-indexed, so row 49 is the row that says 50

You can fire it in the viewDidLoad method for the UIViewController managing the view which contains the UIPickerView.

(It could also be that you can specify the default value in Interface Builder, but I'm not sure and I didn't check...)

0

精彩评论

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