の無効化に問題がありNSTimer
ます。以下の関数でaを初期化NSTimer
します。
-(void) initLTTimer{
[self shutLTTimer];
[self setQuestion:questionCounter];
isQuestionAttempt=NO;
tmLeftTime=[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateLeftTime:) userInfo:nil repeats:YES];
NSLog(@"Timer Initialized");
}
updateLeftTime
さらに、セレクターで関数を呼び出しました。
- (void)updateLeftTime:(NSTimer *)theTimer {
NSLog(@"%d",timeCounter);
timeCounter+=1;
tfLeftTime.text=[NSString stringWithFormat:@"%d", (QUESTION_TIME_LIMIT-timeCounter)];
if (timeCounter>=QUESTION_TIME_LIMIT) {
if (isQuestionAttempt==NO) {
[self increaseDropShots];
}
[self setQuestionBg];
timeCounter=0;
[self shutLTTimer];
[self updateQuestion:nil];
}
}
この関数[self increaseDropShots];
は上記の関数で呼び出されます。これがこの関数のコードです
-(void)increaseDropShots
{
NSString *imgName = @"DactiveRetake";
if (IS_IPAD) {
imgName = [imgName stringByAppendingString:@"_ipad"];
}
wrongAttemp+=1;
for (int i =1; i<=wrongAttemp; i++ )
{
UIImageView *img=(UIImageView *)[self.view viewWithTag:i+50];
[img setImage:[UIImage imageNamed:imgName]];
}
NSLog(@"Question dropped counter: %d",wrongAttemp);
if (wrongAttemp == 3)
{
[self shutLTTimer];
[CommonFunctions initGlobalVars];
[Bgplayer stop];
[Bgplayer release];
OverPageViewController *opvc=[[OverPageViewController alloc] initWithNibName:[CommonFunctions getXIBFile:@"OverPageViewController"] bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:opvc animated:YES];
[opvc release];
}
}
この関数では、このタイマーを強制終了していますが、できません。
-(void) shutLTTimer{
if ([tmLeftTime isValid]) {
[tmLeftTime invalidate];
tmLeftTime=nil;
}
これは私のアプリケーションのシナリオ全体です
何が問題なのか教えてください。