0

我有一个选项卡视图,将选项卡“秒表”和计时器分开。”这些由 ClockViewController.m 和 h 控制。

我的问题是秒表初始化得很好。我的代码在程序打开时应该做什么工作。但是,我的计时器代码没有。

ClockViewController.m 的相关代码:

初始化 ClockViewController:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Initialization code here.
        if (startedSW == FALSE)
        {
            [self initializeTimer:nil];
        }

        if (isTimerRunning == FALSE)
        {
        [self initializeStopwatch:nil];
        }
    }

    return self;
}

initializeStopwatch (这个是正常工作的):

- (void)initializeStopwatch:(id)sender
{

    //Sets the timer to 0 all-around.
    [lblSWTime setStringValue:@"XX:XX:XX"];
    [lblTimeSinceLastLap setStringValue:@"00:00:00"];
}

initializeTimer (非工作的):

- (void)initializeTimer:(id)sender
{
    //Set up the panel to properly be ready to go.
    [btnTimerPause setEnabled:NO];
    [lblTimerTime setStringValue:@"59:59"];
    [lblTimerTime setHidden:NO];
    [lblTimerMillisecs setHidden:NO];

    //Sets up the minutes pop-up button to have the correct options in it.
    int minutesIntToAdd = 1;
    NSString *minutesIntToAddString;
    for (int i = 1; i < 60; i++)
    {
        //Adds 1-59 to the pop-up button.
        minutesIntToAddString = [NSString stringWithFormat:@"%d", minutesIntToAdd];
        [btnMinutesButton addItemWithTitle:minutesIntToAddString];
        minutesIntToAdd++;
    }

    //Sets up the seconds pop-up button to have the correct options in it.
    int secondsIntToAdd = 1;
    NSString *secondsIntToAddString;
    for (int j = 1; j < 60; j++)
    {
        //Adds 1-59 to the pop-up button.
        secondsIntToAddString = [NSString stringWithFormat:@"%d", secondsIntToAdd];
        [btnSecondsButton addItemWithTitle:secondsIntToAddString];
        secondsIntToAdd++;
    }
}

我的问题是 initializeTimer 中的所有代码都不起作用。加载/初始化 xib 时,它没有运行。

我知道这个问题令人困惑,但任何帮助将不胜感激。

4

0 回答 0