iphone UIPicker 默认位置

发布于 2024-09-06 06:09:49 字数 94 浏览 1 评论 0原文

有没有办法为 UIPicker 设置默认位置?我的意思是,如果用户可以在 UIPicker 中选择 1 到 100 之间的任何数字,我可以将其设置为自动从 50 开始吗​​?

Is there a way to 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叶落知秋 2024-09-13 06:09:49

您可以像这样使用 selectRow:inComponent:animated:

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

您可以在 viewDidLoad 方法中触发它,以便 UIViewController 管理包含以下内容的视图: UIPickerView

(也可能你可以在Interface Builder中指定默认值,但我不确定并且我没有检查......)

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...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文