1. Nstimer, can be set for a period of time to execute once, will not get stuck thread
//nstimer not accurate , Cadisplaylink Accurate
Self.Timer = [NstimerScheduledtimerwithtimeinterval:3.0Target: Selfselector:@selector(roll)UserInfo:Nilrepeats:NO];
//nsdefaultrunloopmode The default mode is temporarily not listening once there are scrolling events
Nsrunloopcommonmodes Monitoring when scrolling mode
Self.Timer = [Nstimer Timerwithtimeinterval:1.0 Target: Self Selector:@selector(roll)UserInfo:Nil Repeats:YES];
[[ nsrunloop Currentrunloop" addtimer: _timer formode: nsrunloopcommonmodes " Span style= "font-variant-ligatures:no-common-ligatures; Color: #000000 ">";
// End Method
[self. Timer invalidate];
2.GCD method, you can choose the Cheng in the sub-line
Dispatch_after(Dispatch_time(Dispatch_time_now, (int64_t)(1.0 * nsec_per_sec)), Dispatch_get_main_queue(), ^{
[ self roll];
});
Dispatch_after(Dispatch_time(Dispatch_time_now, (int64_t)(3.0 * Nsec_per_sec)), Dispatch_get_global_queue(Dispatch_queue_priority_default, 0), ^{
[ self roll];
});
3. Delayed execution, no stuck thread
[ Self Performselector:@selector(roll)Withobject:Nil Afterdelay:3.0];
4. Will be stuck thread, not recommended to use
[nsthread sleepfortimeinterval:3.0];
Three ways to delay iOS execution