0
我想與標籤動態添加文本框,以便它可以給獨特價值,每次添加動態文本。而不是增加這些值和希望顯示標籤上....當我點擊按鈕,一個文本框加正給出了值,並將該值添加到先前的值...與標籤部分2
增值成功......但是,當我編輯任何東西或改變或給出另一個值,如(10而不是12),循環將再次運行,因爲這條線
[Txt_New_Estimated addTarget:self action:@selector(C6Loop)forControlEvents:UIControlEventEditingDidEnd];
第二個問題是,當我添加新的文本字段,然後以前的文本字段沒有修改,並沒有添加其餘的文本字段......在添加新的文本字段之前它正常工作,但編輯任何東西循環將再次運行....我要解決這個問題,那麼請檢查此代碼,並提供一些可能的解決方案......我在這裏送我的代碼,請檢查驗證碼...
謝謝你......
-(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 2012-03-15 07:39:17