我想在另一个名为“AdultPayNowViewController”的 ViewContoller 上执行“TotalLabel”计算。我还想执行“x”值,这是用户在“AdultPayNowViewController”上输入数量的 UITextField
//成人票计算器.h
@interface StudentTicketCalculatorViewController : UIViewController {
IBOutlet UITextField *Quantity;
IBOutlet UILabel *Pricelabel;
IBOutlet UILabel *TotalLabel;
IBOutlet UIButton *CheckoutButton;
}
-(IBAction)calculate;
-(IBAction)clear;
@end
\\AdultTicketCalculator.m
-(IBAction)calculate {
float x = ([Quantity.text floatValue]);
float c = x*15;
TotalLabel.text = [[NSString alloc] initWithFormat:@"$%.2f", c];
}
-(IBAction)clear {
Quantity.text =@"";
Pricelabel.text =@"$15.00";
TotalLabel.text =@"";