Objective C - 为用户创建多个文本字段,然后随机选择一个并输出输入的数据
基本上我想做的是:
1)用户设置他想要的选择数量,例如3个选择,即“A”,“B”,“C” [完成此操作]
2) 加载下一个视图并创建适量的框,在本例中为 3 个。这些框首先需要为空,然后用户在框中输入他们的选择。 例如“A”、“B”、“C”
注意:我尝试自动创建多个文本框,但我发现大约 6 个框后屏幕不会滚动,因此看起来很俗气
3)单击按钮,随机选择其中一个文本框。然后,从这个随机选择的框中输入的数据将显示在 NSLog 或标签或文件中,然后我将在另一个视图中使用它们。
谢谢丹
Basically what I am trying to do is:
1) The user sets the number of choices he wants e.g. 3 choices which are "A", "B", "C"
[Done this]
2) The next view is loaded and the right amount of boxes are created, 3 in this case. The boxes need to be blank at first and then the user enters their choices into the boxes.
e.g. "A", "B", "C"
Note: I tried create multiple text boxes automatically, but I found that after about 6 boxes the screen wouldn't scroll and therefore looked very tacky
3)At a click of a button, one of the textboxes is selected randomly. The inputed data from this randomly selected box is then displayed in NSLog or Label or file, which i will then use in another view.
Thanks
Dan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿,你可以从第二个视图中创建一个滚动视图。这样,您仍然可以自动创建文本字段,并且屏幕将滚动。查看此链接有关如何创建滚动视图的更多信息。也许您可以动态调整滚动视图的大小(取决于您有多少文本字段)。
关于选择随机文本字段,请使用
arc4random()
有关更多信息,请参阅 这里。Hey, you could make a scrollView out of the 2th view. That way, you can still automatically create textfields, and the screen will scroll. Check out this link for more information on how to create a scrollview. Perhaps you can make the scrollview's size dynamically (depending on how much textfields you have).
About selecting a random textfield, use
arc4random()
More about that can be found here.