如何让IOS选择器视图默认选择特定值

发布于 2025-01-10 23:11:36 字数 204 浏览 6 评论 0原文

我在选择器视图上遇到问题。当选择器打开时,我希望焦点位于活动值 70 而不是 42 上。为此,我使用了像 selected 这样的通用属性,但没有成功。

屏幕截图

知道如何解决这个问题吗? 谢谢

I'm getting an issue on a picker view. When the picker is opened I would like the focus to be on the active value that is 70 instead of 42. I have used generic attribute like selected for this purpose but no luck.

Screenshot

Any idea how to solve this please?
Thanks

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

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

发布评论

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

评论(1

一城柳絮吹成雪 2025-01-17 23:11:37

您可以通过以下方法设置默认选择值。 (在下面的代码中,1是您要选择的行的索引)

picker.selectRow(1, inComponent:0, animated:true)

you can set the default selected value by the following method. (in below code, 1 is the index of the row you want to select)

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