ios : display the array value in uitextfield?
在文本字段中显示键值。
这就是我获取数据的方式:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
-(void)textFieldDidBeginEditing:(UITextField *)textField{
if (txtviolation.editing == YES) [[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]]; pickerV = [[UIPickerView alloc]init]; [[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]]; |
这是显示数据的方式:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { if (flag==1) { return ViolationA.count; } else if (flag==2) { return VTypeA.count; } return 0; } – (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component return 0; -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component txtviolation.text =[NSString stringWithFormat:@"%@", [ViolationA objectAtIndex:row]]; } |
我无法绑定:
点击文本框然后打开 uipicker 视图但不显示标题名称只显示 ‘{‘ 符号。
然后滚动它以设置数组键和值的值,但我只设置值。
1
2 3 4 5 6 7 8 9 10 11 |
uitextfield setvalue:
{ "violation_name" ="Street Light"; } and uipickerview display: then to select any value to set in text field. |
uipickerview 执行选择文本字段不使用任何按钮
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{ return 1; } -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component – (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component } -(void)textFieldDidBeginEditing:(UITextField *)textField if (txtviolation.editing == YES) |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/268668.html