请问这个定时器的使用错在哪里? 主要是因为这句setFireDate,设置它的时候把3分钟时间加上 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用这个方法比较好: performSelector: withObject:afterDelay: setFireDate顾名思义,表示执行Timer的时间,你指定的是一个过去的值,就被命中了 写两个函数来控制, 一个重新创建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]; app在运行过程中隐藏状态栏但存在了黑影该怎么去除?? 拖动tableview把cell里textview的内容都清空了 请问各位iphone开发达人,我应该怎么学? 如何实现图片放大后逐渐清晰 位域问题 数据截获 修改替换 技术 【进来吧,很easy】求改这段TableView代码 请问有会用 githup 的吗? iOS请求webservice接口需要明确知道什么信息 IOS怎么修改照片的名字 oc 的GDC和block UIWebView 的 webViewDidFinishLoad not called ??
performSelector: withObject:afterDelay:
-(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];