テキストフィールドを作成しました動的にテキストフィールドに入力されたテキストにアクセスする必要があります。これを行うのを手伝ってください。
-(void)createHHDynamicFieldForYValue:(int )yVal
{
NSString *lblStr=[[NSString alloc]initWithString:[[healthyHeartFieldsAry objectAtIndex:tagHHCount] objectForKey:@"TestName"]];
dynamicHealthyHeartLbl=[[UILabel alloc] initWithFrame:CGRectMake(50,yVal,278,45)];
dynamicHealthyHeartLbl.backgroundColor=[UIColor clearColor];
dynamicHealthyHeartLbl.textColor=[UIColor colorWithRed:17/255.0 green:61/255.0 blue:83/255.0 alpha:1];
dynamicHealthyHeartLbl.textAlignment = UITextAlignmentLeft;
dynamicHealthyHeartLbl.text=lblStr;
dynamicHealthyHeartLbl.font = [UIFont boldSystemFontOfSize:18];
[healthyHeartScrollView addSubview:dynamicHealthyHeartLbl];
[dynamicHealthyHeartLbl release];
[lblStr release];
dynamicHealthyHeartImgVw=[[UIImageView alloc] initWithFrame:CGRectMake(375, yVal, 278,kTxtImgHgVal)];
dynamicHealthyHeartImgVw.image=[UIImage imageNamed:@"birth_date.png"];
dynamicHealthyHeartImgVw.backgroundColor=[UIColor clearColor];
[healthyHeartScrollView addSubview:dynamicHealthyHeartImgVw];
[dynamicHealthyHeartImgVw release];
dynamicHealthyHeartTxtFld=[[UITextField alloc] initWithFrame:CGRectMake(380,yVal,278,kTxtImgHgVal )];
dynamicHealthyHeartTxtFld.borderStyle = UITextBorderStyleNone;
dynamicHealthyHeartTxtFld.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
dynamicHealthyHeartTxtFld.textAlignment=UITextAlignmentLeft;
dynamicHealthyHeartTxtFld.textColor=[UIColor colorWithRed:17/255.0 green:61/255.0 blue:83/255.0 alpha:1];
dynamicHealthyHeartTxtFld.font = [UIFont systemFontOfSize:18];
dynamicHealthyHeartTxtFld.backgroundColor = [UIColor clearColor];
dynamicHealthyHeartTxtFld.autocorrectionType = UITextAutocorrectionTypeNo;
dynamicHealthyHeartTxtFld.returnKeyType = UIReturnKeyDone;
dynamicHealthyHeartTxtFld.clearButtonMode = UITextFieldViewModeWhileEditing;
dynamicHealthyHeartTxtFld.autocapitalizationType=UITextAutocapitalizationTypeNone;
dynamicHealthyHeartTxtFld.delegate = self;
dynamicHealthyHeartTxtFld.placeholder=[[healthyHeartFieldsAry objectAtIndex:tagHHCount] objectForKey:@"TestName"];
dynamicHealthyHeartTxtFld.tag=tagHHCount;
[healthyHeartScrollView addSubview:dynamicHealthyHeartTxtFld];
[dynamicHealthyHeartTxtFld release];
[healthyHeart_TxtFldAry addObject:dynamicHealthyHeartTxtFld];
[dynamicHealthyHeartTxtFld release];
tagHHCount++;
}
int YVal=35;
tagHHCount=0;
NSLog(@"healthyHeartFieldsAry Count %d",[healthyHeartFieldsAry count]);
for (int i=0; i<[healthyHeartFieldsAry count]; i++)
{
[self createHHDynamicFieldForYValue:YVal];
YVal=YVal+80;
}
In TextField で編集が終了しました
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if(enteredHealthyHeart)
{
for(int i=0;i<[healthyHeart_TxtFldAry count];i++)
{
if(textField == [healthyHeart_TxtFldAry objectAtIndex:i])
{
getHHTag=textField.tag;
// UITextField *tempTxtFld=[healthyHeart_TxtFldAry objectAtIndex:getHHTag];
dynamicHealthyHeartTxtFld=[healthyHeart_TxtFldAry objectAtIndex:getHHTag];
if([dynamicHealthyHeartTxtFld.text length]>0)
{
NSString *tempStr=dynamicHealthyHeartTxtFld.text;
NSLog(@"tempStr %@",tempStr);
if(![self checkForDecimalValue:tempStr])
{
Custom_Alert *alert=[[Custom_Alert alloc] initWithTitle:@"Alert" message:@"Please Enter Numeric Values" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
if(([tempStr intValue] >= [[[healthyHeartFieldsAry objectAtIndex:getHHTag] objectForKey:@"MinVal"] intValue])&&([tempStr intValue] <= [[[healthyHeartFieldsAry objectAtIndex:getHHTag]objectForKey:@"MaxVal"]intValue]))
{
NSLog(@"validation Succcess!!!");
}
else
{
Custom_Alert *alert=[[Custom_Alert alloc] initWithTitle:@"Alert" message:@"Please check the Details" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
}
[textField resignFirstResponder];
//return YES;
}
}
}
}
textField テキストにアクセスする方法を知りたいです。入力されたテキストフィールドのテキストを識別する方法。何か助けて???