Objective C - 为用户创建多个文本字段,然后随机选择一个并输出输入的数据

发布于 2024-11-02 16:19:05 字数 324 浏览 6 评论 0原文

基本上我想做的是:

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技术交流群

发布评论

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

评论(1

秋风の叶未落 2024-11-09 16:19:05

嘿,你可以从第二个视图中创建一个滚动视图。这样,您仍然可以自动创建文本字段,并且屏幕将滚动。查看链接有关如何创建滚动视图的更多信息。也许您可以动态调整滚动视图的大小(取决于您有多少文本字段)。

关于选择随机文本字段,请使用 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.

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