我有一个标签视图,将标签“Stopwatch”和计时器分开。“这些标签由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时,它没有运行它。
我知道这个问题令人困惑,但任何帮助都会受到赞赏。