在iPhone应用程序中关闭UIpicker [英] Closing a UIpicker in an iphone app

查看:91
本文介绍了在iPhone应用程序中关闭UIpicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iphone dev的新手。我正在制作的应用程序使用选择器从用户输入值。我设法隐藏了选择器,直到用户点击按钮。我在viewdidload中使用了 mypicker.alpha = 0; ,因此当程序启动时,选择器是不可见的。当用户点击开始按钮时,它执行代码 mypicker.alpha = 1; 。我希望在用户选择值后关闭选择器。我怎么做?任何人都有任何提示或教程?我看了几眼,但他们很困惑!另外如何让拾取器自下而上显示? (比如键盘!)

I'm new to the iphone dev. The app I'm making uses the picker to input value from the user. I have managed to make the picker hidden until the user hits the button. I used the mypicker.alpha = 0; in viewdidload so the the picker is invisible when the program starts. When the user hits the start button it executes the code mypicker.alpha=1;. I want the picker to close after the user chooses a value. How do I do that? anyone have any hints or tutorials ? I looked at few but they were confusing! Also how do I make the picker appear from the bottom up ? (like the keyboard !)

推荐答案

我最近开始使用的一种方法是在拾取器后面放一个阴影按钮,大透明黑色按钮屏幕的大小,颜色黑色与alpha = 0.3([UIColor colorWithWhite:0 alpha:0.3f]我认为是)。除了拾取器之外,这只是在屏幕的其余部分放置一个透明的阴影,类似于使用UIAlertView时的外观。然后挂钩按钮,以便它将resignFirstResponder发送给选择器。现在,当用户完成拾取时,他们只需点击阴影区域中拾取器外的任何位置,按钮就会重新选择拾取器,拾取器可以向下滑动,按钮会以动画淡出。

One method I recently started using is to put a shade button behind the picker, a large transparent black button the size of the screen, color black with alpha=0.3 ([UIColor colorWithWhite:0 alpha:0.3f] I think it was). This just puts a transparent "shade" over the rest of the screen except for the picker, similar to how it looks when you use UIAlertView. Then hook up the button so that it sends resignFirstResponder to the picker. Now when the user is done picking, they just tap anywhere outside the picker in the shaded area, and the button resigns the picker, and the picker can be slid down and the button faded out with an animation.

可以完成选择器上下滑动动画,我在家里有代码,但现在无法访问它。您可以使它看起来像键盘一样,并发送键盘发送的相同通知。

The picker slide up/down animation can be done and I have the code for it at home but don't have access to it right now. You can make it appear just like the keyboard and send the same notifications that the keyboard sends.

这篇关于在iPhone应用程序中关闭UIpicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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