私は毎回ユニークな値を与えることができるように、タグを使ってテキストフィールドを動的に追加します。これらの値を追加してラベルに表示したいのですが...ボタンを1つクリックするとテキストフィールドを追加して値を与え、その値を前の値に加算します...タグ付きの動的テキストフィールドの追加2
値加算成功...私は何を編集したり、そのような(10の代わりに12)などの別の値を変更したり、与えるループがあるため、この行の
[Txt_New_Estimated addTarget:自己アクション:@selector(C6Loop)forControlEvents:UIControlEventEditingDidEnd再び実行されます。
2番目の問題は、新しいテキストフィールドを追加すると以前のテキストフィールドが変更されず、残りのテキストフィールドに追加されないということです。新しいテキストフィールドを追加する前に正しく動作しますが、この問題を克服したいので、このコードをチェックして、いくつかの可能な解決策を与えてください...私はここに私のコードを送信しています。このコードをチェックしてください...
はありがとうございました...
-(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;
[email protected]"";
//[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];
}
最初のタグ値は何ですか? – iNeal