简体   繁体   English

需要有关同时使用UIPickerView和UIActionSheet的新手指南(仅在点击文本框时才显示pickerview)

[英]Need a noob guide on using the UIPickerView and UIActionSheet together(only show pickerview when a textfield is tap)

I have been searching for days on on how I can use a pickerview on my textfield... I am very new to Ios programming and I have been searching the web for snippets of code that I can use on my program.. 我一直在寻找如何在文本字段上使用pickerview的日子。我对Ios编程非常陌生,并且我一直在网上搜索可在程序上使用的代码片段。

Basically this is just what I want: I have a one of my textfield that ask for which Equipment type.. there is only 4 items to select on. 基本上,这就是我想要的:我有一个文本字段,询问哪种设备类型。.只有4个选项可供选择。 I want the program to show the picker view when they tap the equiptextfield and fill it with the item that they selected from the picker view.. then the picker view should be dismissed or go to the next field. 我希望程序在他们轻敲Equiptextfield并显示从选择器视图中选择的项目时显示选择器视图。然后应该关闭选择器视图或转到下一个字段。

I found out online that the best way to do this is to use UIActionSheet to show/hide the pickerview only when that textfield was selected. 我在网上发现,执行此操作的最佳方法是仅在选择该文本字段时才使用UIActionSheet显示/隐藏pickerview。

I need to know what I have to add on these items: -my nib file(currently it has 1 view with a scrollview under it and all the fields is on it) View -scroll View -my textfields under it... 我需要知道我必须在这些项目上添加的内容:-我的笔尖文件(当前它具有1个视图,在其下具有滚动视图,并且所有字段都在其上)视图-滚动视图-在其下的我的文本字段...

-my header file... im really a noob so I really need to ask for the code -我的头文件...我真的是菜鸟,所以我真的需要询问代码

-my implementation file.. same as the header, I need the code please -我的实现文件..与标题相同,请输入代码

Please dont think I didnt do my search because I did and there is just so much stuff online that its hard to figure out which to use, and those that I tried gave me errors. 请不要以为我没有做搜索,因为我做过,而且网上有太多东西,很难弄清楚该使用哪个,而我尝试过的东西却给了我错误。

thank you so much for any help anyone can provide. 非常感谢您提供的任何帮助。

Apple provides a good example of UIKit's controls. Apple提供了UIKit控件的一个很好的例子。 UICatalog UI目录

This sample is a catalog exhibiting many views and controls in the UIKit framework, along with their various properties and styles. 此示例是一个目录,展示了UIKit框架中的许多视图和控件以及它们的各种属性和样式。

If you need code to create specific UI controls or views, refer to this sample and it should give you a good head start in building your user interface. 如果您需要代码来创建特定的UI控件或视图,请参考此示例,它应该为您建立用户界面提供良好的起点。 In most cases you can simply copy and paste the code snippets you need. 在大多数情况下,您只需复制并粘贴所需的代码段即可。

Try. 尝试。 Do not be afraid to fail. 不要害怕失败。 Errors are experience too. 错误也是经验。

Btw, why are you using UITextField for such tasks? 顺便说一句,为什么要使用UITextField执行此类任务? I suppose, the better way to select the one option from four is to use UISegmentedControl with 4 segments. 我想,从四个中选择一个选项的更好方法是对四个细分使用UISegmentedControl。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM