这是 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];
这是视图控制器二:
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 中,我想用 ViewControllerTwo 的总和减去 ViewControllerOne 的总和,并在标签中显示答案。