因此,我第一次使用選項卡式應用程序,需要一些幫助。如何使用選項卡式應用程序
主要有兩種觀點的應用程序:
- 第一屆有一個基本的工資總額計算器。
- 第二個選項可以選擇稅收並進行更改。
我的問題是如何從視圖1中獲取信息,並在視圖2中使用它們,而不必重新輸入數字?
我也使用.xib而不是storybords。
@synthesize totalpay, overtime;
//initWithNibName information is in here
////
//View did load and memory
////
//button to calculate the inputed hours and hourly pay
- (IBAction)calculate:(id)sender
{
NSString *inVal = _hours.text;
NSString *inVal2 = _pay.text;
double hours = [inVal doubleValue];
double pay = [inVal2 doubleValue];
//check for overtime
overtime = hours - 40;
if(overtime > 0)
{
totalpay = ((pay * 1.5) * overtime) + ((hours - overtime) * pay);
_overtimeOutput.text = [NSString stringWithFormat:@"Overtime Pay this week: $%.2f", totalpay];
}
else
{
totalpay = hours * pay;
_baseOutput.text = [NSString stringWithFormat:@"Pay this week: $%.2f", totalpay];
}
}