主要说明NSTimer的具体实用。
Creating a Timer
+ scheduledTimerWithTimeInterval:invocation:repeats:
+ scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
+ timerWithTimeInterval:invocation:repeats:
+ timerWithTimeInterval:target:selector:userInfo:repeats:
– initWithFireDate:interval:target:selector:userInfo:repeats:
Firing a Timer
– fire
Stopping a Timer
– invalidate
Information About a Timer
– isValid
– fireDate
– setFireDate:
– timeInterval
– userInfo
-(IBAction) onPlay:(id)sender
{
if(timer == nil)
{
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(checkThem:) userInfo:nil repeats:YES] ;
}
else
{
[timer invalidate];
i = 0;
timer = nil;
}
}
-(void) checkThem:(NSTimer *) aTimer
{
NSLog(@"checkThem");
NSString *path =[paths objectAtIndex:i];//paths:deposit a lot of the imageFilePath
dosomething.....//主要是图片的显示,自定义View
++i;
if((i+1) == [paths count])
{
i = 0;
}
}
[Cocoa]_[初级]_[NSTimer在Cocoa中的应用,主要以多张图片切换的播放和停止]
最新推荐文章于 2024-08-11 16:56:49 发布