0

これはViewControllerOneです:

- (IBAction)total {

float a = ([textfield1.text floatValue]);
float b = ([textfield2.text floatValue]);
float c = ([textfield3.text floatValue]);
float d = ([textfield4.text floatValue]);
float e = ([textfield5.text floatValue]);
float f = a+b+c+d+e+([textfield6.text floatValue]);

total.text = [[NSString alloc] initWithFormat:@"$%.2f", f];

これはView ControllerTwoです:

float g = ([textfield1.text floatValue]);
float h = ([textfield2.text floatValue]);
float i = ([textfield3.text floatValue]);
float j = ([textfield4.text floatValue]);
float k = ([textfield5.text floatValue]);
float l = a+b+c+d+e+([textfield6.text floatValue]);
totalTwo.text = [[NSString alloc] initWithFormat:@"$%.2f", l];

ViewControllerThree では、ViewControllerOne からの合計を ViewControllerTwo の合計で減算し、その答えをラベルに表示したいと考えています。

4

1 に答える 1

0

sum total.text&の値totalTwo.textappDelegatelikeに保存する

AppDelegate.h ファイル内

float totalOne, totalTwo;
@propery(nonatomic)float totalOne, totalTwo;

AppDelgate.m ファイルでは、

@synthesize totalOne, totalTwo;

- (IBAction)total 
{
   //Create the instance of appDelegate as
   AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
   float a = ([textfield1.text floatValue]);
   float b = ([textfield2.text floatValue]);
   float c = ([textfield3.text floatValue]);
   float d = ([textfield4.text floatValue]);
   float e = ([textfield5.text floatValue]);
   float f = a+b+c+d+e+([textfield6.text floatValue]);
   app.totalOne = f;
   total.text = [[NSString alloc] initWithFormat:@"$%.2f", f];
}

//Create the instance of appDelegate as
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
float g = ([textfield1.text floatValue]);
float h = ([textfield2.text floatValue]);
float i = ([textfield3.text floatValue]);
float j = ([textfield4.text floatValue]);
float k = ([textfield5.text floatValue]);
float l = a+b+c+d+e+([textfield6.text floatValue]);
app.totalTwo = l;
totalTwo.text = [[NSString alloc] initWithFormat:@"$%.2f", l];

-(IBAction)btnCalculate
{
    //Create the instance of appDelegate as
    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    totalthree = app.totalOne - app.totalTwo;
    lbl.text = [NSString StringWithFormat:@"$%.2f", totalThree];
}
于 2013-02-20T04:35:15.673 に答える