主要是因为这句setFireDate,设置它的时候把3分钟时间加上

解决方案 »

  1.   

    用这个方法比较好: 
    performSelector: withObject:afterDelay:
      

  2.   

    setFireDate顾名思义,表示执行Timer的时间,你指定的是一个过去的值,就被命中了
      

  3.   

    写两个函数来控制, 一个重新创建NSTimer ,一个设置timer失效 
    -(void)startMyTimer;
    -(void)invalidMyTimer;-(void)startMyTimer {
          myTimer = [NSTimer  scheduledTimerWithTimeInterval:180 target:self selector:@selector(countscore) userInfo:nil repeats:YES];
    }
    -(void)invalidateMyTimer {
              [myTimer invalidate];
              myTimer  = nil; 
    }你上面的代码,做下相应的修改
    -(void) countscore
    {
        NSString * hint =[NSString stringWithFormat:@"%d", m_right];
         
        [self invalidateMyTimer]; 
         
        UIAlertView * alert_hint = [[UIAlertView alloc]initWithTitle:@"" message:hint  delegate:nil cancelButtonTitle:@"OK"  otherButtonTitles:nil];
        [alert_hint show];   
    }
     
    - (void)viewDidLoad

      ......
      [self startMyTimer];
    .....
    }
    在点击alert 的OK按钮后,在alert的代理方法中,重新创建NSTimer实例 ,执行[self startMyTimer];