开发者

Iphone:More than one textfield in a table view cell

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


  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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜