初始化 UIPickerView

发布于 2024-08-13 17:17:59 字数 339 浏览 5 评论 0原文

我想用最简单的方法创建一个 UIPickerView ,因为我所知道的所有内容都不足以帮助我

好吧,我想说的是,我正在尝试获取一个 UISegmented ,最终将创建一个 UIPickerView 但我想创建一个当我选择动画分段控件中的一个分段时显示的 UIPickerView,并且 pickerview 应该使用具有红色、绿色、蓝色等颜色的数组


好吧,我要说的是,我正在尝试获取一个将结束的 UISegmented创建一个 UIPickerView 但我想创建一个 UIPickerView,当我选择动画分段控件中的一个片段时,它会显示出来,而且 pickerview 应该使用一个具有红色、绿色、蓝色等颜色的数组

I want to create a UIPickerView with the easiest way possible, because all of what I know Is not enough to help me

Ok what I ment is that I am trying to get a UISegmented that will end up creating a UIPickerView but I want to create a UIPickerView that shows up when I select one of the segments in the segmented control animated, and also the pickerview is supposed to use an array that has colors like red green blue


Ok what I ment is that I am trying to get a UISegmented that will end up creating a UIPickerView but I want to create a UIPickerView that shows up when I select one of the segments in the segmented control animated, and also the pickerview is supposed to use an array that has colors like red green blue

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

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

发布评论

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

评论(2

愁以何悠 2024-08-20 17:17:59

对于您的 UISegmentedControl,您需要注册目标操作方法。例如:

[segmentedControl addTarget:self
                 action:@selector(updatePicker:)
       forControlEvents:UIControlEventValueChanged];

在 updatePicker 内部,设置一个与您想要在选择器中显示的内容相对应的变量。然后,向您的选择器实例(您应该只有该类的一个实例)发送 reloadAllComponents 消息。这将通过查询委托的新数据来更新选择器。在您的委托(可能都是同一类)中,您需要检查在 updatePicker 中设置的变量的值,以确定要返回给选择器的数据。

For your UISegmentedControl, you'll need to register target-action methods. For example:

[segmentedControl addTarget:self
                 action:@selector(updatePicker:)
       forControlEvents:UIControlEventValueChanged];

Inside of updatePicker, set a variable that corresponds to whatever you want to show in your picker. Then, to your picker instance (you should only have one instance of this class), send the reloadAllComponents message. This will update the picker by querying the delegate for new data. In your delegate (which can probably all be the same class), you'll want to check the value of the variable you set in updatePicker to determine what data to return to the picker.

清欢 2024-08-20 17:17:59

这个页面有关于如何在Swift中以编程方式添加UIPickerView的视频和说明,即它没有使用 Interface Builder 或 Story Board,一切都可以通过几行代码完成。

http://www.appswiftprogramming.com/pg/2171/UIPickerView_Programmatically

您可以添加您的如果您想要更高级的东西,请在 UIPickerView 中自定义视图。这也表明了这一点。

This page has video and instructions on how to add UIPickerView programmatically in Swift, i.e. it does not use Interface Builder or Story Board, everything is done in a few lines of code.

http://www.appswiftprogramming.com/pg/2171/UIPickerView_Programmatically

You can add your custom view in the UIPickerView if you want something more advanced. It shows that too.

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