iPhone:表视图单元格中有多个文本字段

发布于 2024-09-29 15:35:27 字数 897 浏览 0 评论 0原文

完整问题

我认为这是一个关于 tableview 单元格中文本字段的

,它看起来像 [IP xxx.xxx.xxx.xxx ] <--这是 tableview 中的一个单元格

所以...这意味着单元格中至少有 4 个文本字段

但是我有一些问题

****1.**如何向 cell.accessoryView 添加更多文本字段?********

这就是我在单元格中设置文本字段的方法,

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 185, 30)];
cell.accessoryView = textField;

但它在单元格中只有一个文本字段,所以.. .我可以在一个单元格中拥有多个附件视图吗?

2.表格视图有3行,1.IP 2.子网掩码3.网关第2个完成按钮是“下一步”按钮,最后一个是“完成”按钮,我之前看过此讨论,但答案是行不通的对我来说,我认为问题是我没有给默认的完成按钮一个标签。所以当我按“下一步”按钮时,它不会跳转到下一个文本字段。

如何给默认的完成按钮一个标签?

3.如何让文本字段记录我输入的内容?离开视图后总是清晰的... 有教程吗?

4.如何比较输入文本是否都是0~255之间的整数并设置最大长度为3个数字

I think is a little complete problem

about textfield in tableview cell

it looks like [IP xxx.xxx.xxx.xxx ] <--this is a cell in tableview

So...It means at least 4 textfield in a cell

But I have some questions

****1.**How to add more textfield to cell.accessoryView ?******

This is how I set a textfield in a cell

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 185, 30)];
cell.accessoryView = textField;

But it only has one textfield in a cell ,so ...can I have mutiple accessory view in a cell ?

2.The tableview got 3 rows ,1.IP 2.Subnet Mask 3.Gateway first 2 done button is "Next" button ,Last one is "Done" button,I look this discussion before ,but the answer is not works for me ,I think the problem is I didn't give a default done button a tag .So when I press Next button,It won't jump to next textfield.

How to give a default done button a tag ?

3.How to let textfield keep record what I type ?It always clear after I leave the view...
any tutorials ?

4.How compare input text is all integer between 0~255 and set max length is 3 numbers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

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

评论(1

氛圍 2024-10-06 15:35:27
  1. 如果您确实想添加多个 UITextField,则必须将它们添加为 UITableViewCell 的 contentView 的子视图。所以你的代码看起来像这样......

    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 185, 30)];
    [[cell contentView] addSubview:textField];

  2. 您应该在 UITextField 上设置 tag 属性。使用此标记属性来标识您的文本字段,以便您可以使用键盘上的“下一步”或“完成”键在它们之间导航。

  3. 如果对您尝试构建的应用程序没有更多的了解,这个问题很难回答。当您离开视图时,您将必须检查每个文本字段的“文本”属性以获取当前在其中输入的内容。

  4. 您可以通过将“length”发送到我上面提到的文本属性来获取长度。至于最大长度,您将必须使用 UITextField 的委托来监视进入 textField 的文本的更改。您可以在此处对其进行限制。

希望我能帮一点忙。

  1. If you really want to add more than one UITextField you will have to add them as subviews of UITableViewCell's contentView. So your code would look like so...

    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 185, 30)];
    [[cell contentView] addSubview:textField];

  2. You should be setting the tag property on your UITextField. Use this tag property to identify your text fields so you can navigate between them using the 'Next' or 'Done' key on the keyboard.

  3. Without more knowledge of the application you are attempting to build, this is difficult to answer. When you leave the view you're going to have to check each text field's 'text' property to get what is currently typed in it.

  4. You can get the length by sending 'length' to the text property I mentioned above. As for max length, you're going to have to use UITextField's delegate to monitor changes to the text going into the textField. You will be able to cap it here.

Hope I could help a bit.

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