这是我现在还在的代码..
- (voID) scanbuttontouchUpInsIDe { if (check) { position=CGPointMake(14.0f,7.0f); position1=CGPointMake(7.0f,14.0f); check=NO; timer= [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES]; } else { //animation stop code here................. if ([timer isValID]) { [timer invalIDate]; } check=YES; NSLog(@"stopppppppp.....................");// overlayGraphicVIEw.frame = CGRectMake(30,100,32,32);// overlayGraphicVIEw1.frame = CGRectMake(30,152,32); }}-(voID)onTimer{ overlayGraphicVIEw.center = CGPointMake(overlayGraphicVIEw.center.x+position.x,overlayGraphicVIEw.center.y+position.y); if(overlayGraphicVIEw.center.x > 320 || overlayGraphicVIEw.center.x < 0) position.x = -position.x; if(overlayGraphicVIEw.center.y > 480 || overlayGraphicVIEw.center.y < 0) position.y = -position.y; overlayGraphicVIEw1.center = CGPointMake(overlayGraphicVIEw1.center.x+position1.x,overlayGraphicVIEw1.center.y+position1.y); if(overlayGraphicVIEw1.center.x > 320 || overlayGraphicVIEw1.center.x < 0) position1.x = -position1.x; if(overlayGraphicVIEw1.center.y > 480 || overlayGraphicVIEw1.center.y < 0) position1.y = -position1.y;}解决方法 我这样做的方式很简单……
-(voID)onTimer{ overlayGraphicVIEw.center = CGPointMake(overlayGraphicVIEw.center.x+position.x,overlayGraphicVIEw1.center.y+position1.y); if(overlayGraphicVIEw1.center.x > 320 || overlayGraphicVIEw1.center.x < 0) position1.x = -position1.x; if(overlayGraphicVIEw1.center.y > 480 || overlayGraphicVIEw1.center.y < 0) position1.y = -position1.y; }- (voID) scanbuttontouchUpInsIDe { [self performSelector:@selector(timerInvalIDate) withObject:nil afterDelay:60.0]; if (check) { position=CGPointMake(14.0f,14.0f); timer= [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES]; }}-(voID)timerInvalIDate{ if ([timer isValID]) { [timer invalIDate]; }}
覆盖源取自https://github.com/jj0b/OverlayViewTester
总结以上是内存溢出为你收集整理的ios – 从下一个minitue计算当前时间,然后NSTimer不起作用全部内容,希望文章能够帮你解决ios – 从下一个minitue计算当前时间,然后NSTimer不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)