如何在 UIActionSheet 中创建 UIPickerView

发布于 2024-08-13 17:37:43 字数 285 浏览 2 评论 0原文

只是想知道如何使用简单的数组在 UIActionSheet 中创建 UIPickerView 。


好吧,我实际上找到了如何将其放入操作表中,但我更喜欢你的方式,因为它更适用于我的应用程序,谢谢,但我也想知道如何将选项放入 UIPickerView 中,我只是挂断了那部分。我已经有一个包含颜色的数组:红色、绿色、蓝色、黄色、黑色等,但我想知道如果我已经使用过 initwithframe: ,如何将其放入 pickerview 中?请任何人帮忙,我知道这是一个愚蠢的问题,但我正在我的 $$$$$$ Macbook 上绞尽脑汁。

Just want to know how I would make a UIPickerView in a UIActionSheet with a simple array.


Ok well I actually found out how to put it into an action sheet but I like your way better because it applies more to my app, thanks, but I want to also know how put the options into the UIPickerView, I am just hung up on that part of that. I already have an array with the colors: red, green, blue, yellow, black, etc in it but I want to know how to put that into the pickerview if I have already used initwithframe:? Please anyone help I know it is a stupid question but I'm racking my head on my $$$$$$ Macbook.

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

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

发布评论

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

评论(1

仅冇旳回忆 2024-08-20 17:37:43

你不想那样做。相反,在 Interface Builder 中创建 UIPickerView 并将其连接到视图控制器中的 Outlet。将其添加为主视图的子视图并设置其框架坐标,使其位于屏幕外的底部边缘下方,x=0,y=480。

然后,当您想要显示选择器时,将其动画到屏幕上,如下所示:

[UIView beginAnimations:nil context:NULL];
[colorPicker setFrame:CGRectMake(0.0f, 416.0f, 320.0f, 216.0f)];
[UIView commitAnimations];

然后在完成选择后隐藏它:

[UIView beginAnimations:nil context:NULL];
[colorPicker setFrame:CGRectMake(0.0f, 480.0f, 320.0f, 216.0f)];
[UIView commitAnimations];

这将导致您的选择器从动画底部向上滑动,并在您选择时向下滑动完成了。

我不认为向 UIActionSheet 添加选择器(如果可能的话)是可取的。

You don't want to do that. Instead, create your UIPickerView in Interface Builder and connect it to an Outlet in your view controller. Add it as a subview of your main view and set its frame coordinates so that it is offscreen just below the bottom edge, x=0, y=480.

Then, when you want to display the picker, animate it onto the screen with something like:

[UIView beginAnimations:nil context:NULL];
[colorPicker setFrame:CGRectMake(0.0f, 416.0f, 320.0f, 216.0f)];
[UIView commitAnimations];

And then hide it when you're done picking with this:

[UIView beginAnimations:nil context:NULL];
[colorPicker setFrame:CGRectMake(0.0f, 480.0f, 320.0f, 216.0f)];
[UIView commitAnimations];

This will cause your picker to slide up from the bottom animated and slide back down when you're done.

I don't think adding a picker to a UIActionSheet, if it's even possible, is advisable.

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