I want To add textfield dynamically with tag so that it can give unique value everytime. And than add those values and want to show on label…. when i click button one textfield add n give the value , and that value Add to the previous value…
Value adding Successfully… But when i edit anything or change or give another value such as (10 instead of 12) the loop will run again because of this line
[Txt_New_Estimated addTarget:self action:@selector(C6Loop) forControlEvents:UIControlEventEditingDidEnd];
2nd problem is that when i add new textfield then previous textfield did not modified and do not add in rest of textfields… before adding new textfield it works properly but when edit anything loop will run again…. i want to overCome this problem, so please check this code and give some possible solution… i am sending my code here Please check this code…
Thank You…
-(void)CreateTextFeildOnRun
{
if (tag ==0)
{
textPosY = 420;
}
for ( i =tag; i<= tag; i++)
{
Txt_New_Estimated = [[UITextField alloc]initWithFrame:CGRectMake(360, textPosY , 130, 65)];
Txt_New_Estimated.delegate = self;
Txt_New_Estimated.text=@"";
//[Txt_New_Estimated setTag:1234];
Txt_New_Estimated.tag = i;
Txt_New_Estimated.clearButtonMode = UITextFieldViewModeWhileEditing;
[Txt_New_Estimated addTarget:self action:@selector(C6Loop) forControlEvents:UIControlEventEditingDidEnd];
Txt_New_Estimated.placeholder = @"Estimated";
Txt_New_Estimated.font = [UIFont fontWithName:@"Arial" size:23];
Txt_New_Estimated.backgroundColor = [UIColor whiteColor];
Txt_New_Estimated.textAlignment = UITextAlignmentCenter;
[scrollview addSubview:Txt_New_Estimated];
}
}
-(void)C6Loop{
Txt_New_ONU.text=Txt_New_Estimated.text;
[self Calculate2];
}
-(void)Calculate2{
int y14=([Txt_New_Estimated.text intValue]);
y14=n;
n=d;
c14= y14+([Txt_New_Estimated.text floatValue]);
n = c14;
[self addest];
}
-(void)addest{
float c1= ([Txt_Engring_Est.text floatValue]) + ([Txt_Weddring_Est.text floatValue]) + ([Txt_Bridal_Est.text floatValue])+ ([Txt_Veil_Est.text floatValue])+ ([Txt_Shoe_Est.text floatValue])+n;
Txt_Total_Est.text = [[NSString alloc] initWithFormat:@"%.2f",c1];
}
Please check this line might be a problem.
you are assigning same value to i variable and limit is also same.