当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Implementing a form within a TableView

问题描述:

I would like to implement a form to insert data within a TableView in my app.

I would like the form appears as a table, and each row of the table represent a TextField.

What is the right approach to do this?

Any help is appreciated!!

Regards, yassa

网友答案:

If I understood your question right then I would go for custom TableViewCells.

Subclass UITableViewCell. In the init method (initWithStyle, if I am not much mistaken) create the Text Fields and add them to the superview. ([self.view addSubView:myTextField])

In the layoutViewItems method you should arrange the TextField and any other custom view that you may want to create and add in init.

While overwriting both of them, do not forget to call the related superclass method at the very beginning. You may not need [super layoutSubviews] in the event that you do not want to use any of the standard elements of UITableViewCell.

网友答案:

If you are using Storyboard, use the new Static Cell TableView (as opposed to Dynamic Prototypes. This allows for a TableView that you don't have to use the delegate or datasource methods on. You can layout the sections and rows manually in IB. I use it lots for form based views.

分享给朋友:
您可能感兴趣的文章:
随机阅读: