停止ボタンを押してタイマーを停止すると、元の時間にリセットされ、再びカウントダウンが開始されます。私はどこでも見ましたが、見つかったのは「無効化」だけで、機能していません。ストップを押すと時間が止まり、ラベルに元の時間が表示されるようにします。また、自動カウントをオフにして、リリースを試みることができるようにしましたが、エラーが発生しました。
0x10e20a5: movl 16(%edx), %edx EXC_BAD_ACCESS (コード=2, アドレス=0x10)
NSTimer *rockettTimer;
int rocketCount;
@interface FirstViewController ()
@property (strong, nonatomic) IBOutlet UILabel *rocketTimer;
- (IBAction)stopButton:(id)sender;
- (IBAction)startButton:(id)sender;
@end
@implementation FirstViewController
@synthesize rocketTimer;
-(void) rocketTimerRun{
rocketCount = rocketCount - 1;
int minuts = rocketCount / 60;
int seconds = rocketCount - (minuts * 60);
NSString *timerOutput = [NSString stringWithFormat:@"%d:%.2d", minuts, seconds];
rocketTimer.text = timerOutput;
}
- (IBAction)startButton:(id)sender {
rocketCount = 180;
rockettTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(rocketTimerRun) userInfo:nil repeats:YES];
- (IBAction)stopButton:(id)sender {
[rockettTimer invalidate];
//[rockettTimer release];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setRocketTimer:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end