Objective-C:获取以编程方式创build的文本字段的单个string

经过这个查询的解决scheme之后,当我打印如下所示的mutableArray时,我得到日志中的输出。

*Date Project name :* Save button : ( Def ) 

其中“Def”是在dynamic创build的文本字段中input的文本。 我想提取“Def”并显示在login保存button点击。 这是代码

 - (IBAction)save:(id)sender { for(UITextField *field in self.scroll.subviews) { if([field isKindOfClass:[UITextField class]]) { if([[field text] length] > 0) { NSMutableArray *mutableTextArray = [[NSMutableArray alloc] init]; [mutableTextArray addObject:field.text]; NSLog(@"Save button : %@", mutableTextArray); //NSString *str = [str stringByAppendingString:[mutableTextArray objectAtIndex:0]]; //[self fetchStrings:str]; } } } } - (void) fetchStrings:(NSString*)enteredString { NSLog("%@", enteredString); //want 'def' to be displayed here } 

 - (IBAction)save:(id)sender { for(UIView *field in self.scroll.subviews) { if([field isKindOfClass:[UITextField class]]) { if(((UITextField *)field).text.length > 0) { [mutableTextArray addObject:field.text];//mutableTextArray declare this locally in Interfacefile and then initialize the array in viewDidLoad } } } NSLog(@"%@", mutableTextArray); } 

当你创buildUITextField的时候,设置标签并像这样使用。 我希望这会为你工作