如何在UIActionSheet中创建UIPickerView [英] How do I make a UIPickerView in a UIActionSheet

查看:163
本文介绍了如何在UIActionSheet中创建UIPickerView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

实际上找到了如何把它放入一个操作表,但我喜欢你的方式更好,因为它应用更多的我的应用程序,谢谢,但我想知道如何将选项放入UIPickerView,我只是挂在那部分那。我已经有一个数组的颜色:红色,绿色,蓝色,黄色,黑色等,但我想知道如何把它放入pickerview如果我已经使用initwithframe:?请任何人帮助我知道这是一个愚蠢的问题,但我把我的头在我的$$$$$$ Macbook。

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.

推荐答案

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

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.

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

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

这篇关于如何在UIActionSheet中创建UIPickerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆