[英]UIPickerView selection updates NSArray of UITextFields
I have created a UIScrollView
that contains a dynamic number of UIViews.我创建了一个包含动态数量的 UIViews 的
UIScrollView
。 Inside each UIView will be a dynamic number of UItextField
s.每个 UIView 内部将是一个动态数量的
UItextField
s。
The view itself looks like this视图本身看起来像这样
This white boxes are the UIViews and the black boxes are the UITextfield
s.这个白框是
UITextfield
,黑框是UITextfield
s。
I have a method that puts these UITextfield
s into an array of arrays.我有一种方法可以将这些
UITextfield
放入数组数组中。 So you have an array of UIView
s then in each array there is an array of UITextfield
s.所以你有一个
UIView
数组,然后在每个数组中有一个UITextfield
数组。
that code looks like this.该代码看起来像这样。
for(int i = 0; i< viewcount; i++) {
color = color + 20;
NSLog(@"%f", color);
CGFloat y = i * 91;
UIScrollView *axisContainerScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, y,self.view.frame.size.width, 90.0)];
axisContainerScrollView.contentSize = CGSizeMake(600.0, 90.0);
axisContainerScrollView.backgroundColor = [UIColor whiteColor];
[htmlContainerScrollView addSubview:axisContainerScrollView];
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, y,self.view.frame.size.width, 90.0)];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 640.0, 90.0)];
view.backgroundColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:(1.0/i)];;
[axisContainerScrollView addSubview:view];
int cutCount = [cutsString integerValue];
int positions = (view.frame.size.width/cutCount);
for (int i = 0; i < cutCount; i++) {
//first one
UITextField *cutField = [[UITextField alloc] initWithFrame:CGRectMake(((positions*i)-(20/2)+(positions/2)), 25, 20, 20)];
cutField.textColor = [UIColor colorWithRed:0/256.0 green:84/256.0 blue:129/256.0 alpha:1.0];
cutField.font = [UIFont fontWithName:@"Helvetica-Bold" size:25];
cutField.backgroundColor=[UIColor whiteColor];
[view addSubview:cutField];
[columnArrayOfTextFields addObject:cutField]; // array of textfields
}
[rowArrayOfTextFields addObject:columnArrayOfTextFields]; // array of arrays
}
What I would like help with is how to then step through each UITextField
and enter a value from a UIPickerView
.我想要帮助的是如何逐步遍历每个
UITextField
并从UIPickerView
输入一个值。 so as you select values you populate each UITextField
from left to right and progress downwards through each UItextField
.所以当您选择值您填充每个
UITextField
由左到右,并通过每个向下进步UItextField
。
I have a gesture recognizer for the UIPickerView
where it calles a method like this我有一个
UIPickerView
的手势识别器,它调用这样的方法
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pickerTap:)];
I think the NSArray
of NSArrays is a good start but I'm just not sure how to progress from here.我认为 NSArrays 的
NSArray
是一个好的开始,但我不确定如何从这里开始。
If I understand correctly, you can use the tag
property of the UIView
如果我理解正确,您可以使用
UIView
的tag
属性
What I usually do (since I've come to this problem myself) is :我通常做的(因为我自己也遇到过这个问题)是:
A
. A
。 You have a known number of elements and you assign the tags from 1
to n
您有已知数量的元素,并将标签从
1
分配到n
B
. B
。 If you can add/delete/or you just have a dynamic number of elements, multiply prime numbers with 1
, 2
, 3
etc.如果您可以添加/删除/或您只有动态数量的元素,请将素数与
1
、 2
、 3
等相乘。
1
you use prime number 3
.1
行,您使用质数3
。 So your text fields will have tags like 3
, 6
, 9
, 12
, 15
and 18
3
, 6
, 9
, 12
, 15
和18
这样的标签7
.7
。 So you will have your text field tagged with 7
, 14
, 21
, 28
, 35
and 43
7
、 14
、 21
、 28
、 35
和43
3
you use 11
3
行,您使用11
4
you use 13
and so on ...4
行,您使用13
等...... There's a lot of way it can be done, these are just on top of my head or actually what I use, if I haven't understood correctly what you want, feel free to let me know.有很多方法可以完成,这些只是我的头顶或我实际使用的,如果我没有正确理解你想要什么,请随时告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.