我有一个 iPad 应用程序,我想在数组中输入文本字段输入的值,然后执行计算。我正在使用以下代码:
myPieClass.itemArray=[[NSArray alloc]initWithObjects:@"5",@"10",@"15",@"20",@"30", nil];
myPieClass.myColorArray=[[NSArray alloc]initWithObjects:[UIColor purpleColor],[UIColor redColor],[UIColor orangeColor],[UIColor yellowColor],[UIColor greenColor], nil];
myPieClass.radius=100;
上面的代码获取的是静态值,我想从textfield中获取值。
NSString*value1=textFieldOne.text;
然后将此值赋给数组,对于其他 textfiedls 依此类推,我有三个文本字段。
最佳答案
myPieClass.myTextFieldArray = [[NSArray alloc]initWithObjects: textField1.text, textField2.text, textField3.text, textField4.text, nil];
或
NSString *value1 = textField1.text;
NSString *value2 = textField2.text;
NSString *value3 = textField3.text;
myPieClass.myTextFieldArray = [[NSArray alloc]initWithObjects:value1, value2, value3, nil];
关于iphone - 如何使用 ipad 文本字段中输入的值分配数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10241388/