iphone UIPicker default position
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...)
精彩评论