As subject asks, what is the easiest way to achieve the below input form?
正如题目所问的,要达到以下的输入形式,最简单的方法是什么?
Is it using UITableView? Or something else? I tinker around with code a little bit and I think I may be doing more work than I have to. I recall a presentation in which the presenter said that if I am doing too much hacking to get a feature, perhaps I am doing it wrong.
它使用UITableView吗?还是别的?我稍微修改了一下代码,我想我可能做了更多的工作。我记得在一次演讲中,主持人说如果我为了得到一个功能而做了太多的黑客行为,那么我可能做错了。
I searched the web for several frameworks and they are not sufficient. I tried ELCTextField. I try to use IBAForms which looks really good but the sample code is so confusing, I have no idea on how to use it. If you have any sample code, please share it and I would appreciate it. I also try RoundedUITableView and cannot get that to work.
我在web上搜索了几个框架,但它们还不够。我试着ELCTextField。我尝试使用看起来很好的IBAForms,但是示例代码非常混乱,我不知道如何使用它。如果您有任何示例代码,请分享,我将非常感激。我也尝试了RoundedUITableView,但不能让它发挥作用。
Links to the frameworks: 1. ELCTextField: http://www.cocoacontrols.com/platforms/ios/controls/elctextfieldcell 2. IBAForms: http://www.cocoacontrols.com/platforms/ios/controls/ibaforms 3. RoundedUITableView: https://github.com/beetlebugorg/RoundedUITableView
框架链接:1。ELCTextField:http://www.cocoacontrols.com/platforms/ios/controls/elctextfieldcell 2。IBAForms:http://www.cocoacontrols.com/platforms/ios/controls/ibaforms 3。RoundedUITableView:https://github.com/beetlebugorg/RoundedUITableView
PS: When I try to combine RoundedUITableVIew with ELCTextField, everything breaks. It's heartbreaking...
PS:当我尝试将RoundedUITableVIew与ELCTextField合并时,一切都中断了。这是令人心碎……
3 个解决方案
#1
2
You can do this with two UITextField
s set within a container UIView
object. You will have to set the borderColor
, borderWidth
and cornerRadius
. I've created some sample code
illustrating this.
您可以通过在容器UIView对象中设置两个UITextFields来实现这一点。您必须设置边框颜色、边框宽度和边框半径。我已经创建了一些示例代码来说明这一点。
Basically we will lay the two text fields adjacent vertically inside the container view. We will set the container view's clipsToBounds
property to YES
. We will assign borders to all the three objects and add a corner radius to the container view to get the effect as a grouped table view.
基本上,我们将在容器视图中垂直放置相邻的两个文本字段。我们将把容器视图的clipsToBounds属性设为YES。我们将为所有三个对象分配边框,并向容器视图添加一个角半径,以获得分组表视图的效果。
We will also add rightView
and leftView
properties of the two UITextField
objects to get the padding effect.
我们还将添加两个UITextField对象的rightView和leftView属性,以获得填充效果。
#2
2
I'd suggest a UITableView in grouped (UITableViewStyleGrouped) style, with a UITextField added to the table cell(s). You can use the UITextField's placeholder
property to get the gray default text value in the field.
我建议使用分组(uitableviewstylegroups)样式的UITableView,并在表单元格中添加一个UITextField。您可以使用UITextField的占位符属性来获取字段中的灰色默认文本值。
#3
0
I achieved basically the same effect by having an image as the background (although I guess you could place the content in tableView cells) and having a borderless textfield in each space that had default text in it.
我实现了基本相同的效果,使用图像作为背景(尽管我猜您可以将内容放在tableView单元格中),并在每个具有默认文本的空间中使用无边框的textfield。
#1
2
You can do this with two UITextField
s set within a container UIView
object. You will have to set the borderColor
, borderWidth
and cornerRadius
. I've created some sample code
illustrating this.
您可以通过在容器UIView对象中设置两个UITextFields来实现这一点。您必须设置边框颜色、边框宽度和边框半径。我已经创建了一些示例代码来说明这一点。
Basically we will lay the two text fields adjacent vertically inside the container view. We will set the container view's clipsToBounds
property to YES
. We will assign borders to all the three objects and add a corner radius to the container view to get the effect as a grouped table view.
基本上,我们将在容器视图中垂直放置相邻的两个文本字段。我们将把容器视图的clipsToBounds属性设为YES。我们将为所有三个对象分配边框,并向容器视图添加一个角半径,以获得分组表视图的效果。
We will also add rightView
and leftView
properties of the two UITextField
objects to get the padding effect.
我们还将添加两个UITextField对象的rightView和leftView属性,以获得填充效果。
#2
2
I'd suggest a UITableView in grouped (UITableViewStyleGrouped) style, with a UITextField added to the table cell(s). You can use the UITextField's placeholder
property to get the gray default text value in the field.
我建议使用分组(uitableviewstylegroups)样式的UITableView,并在表单元格中添加一个UITextField。您可以使用UITextField的占位符属性来获取字段中的灰色默认文本值。
#3
0
I achieved basically the same effect by having an image as the background (although I guess you could place the content in tableView cells) and having a borderless textfield in each space that had default text in it.
我实现了基本相同的效果,使用图像作为背景(尽管我猜您可以将内容放在tableView单元格中),并在每个具有默认文本的空间中使用无边框的textfield。