私が見るように、そのような単純な解決策はありません。しかし、あなたはまだこれを行うことができます。
最も明白なのは、タイマーを使用して、ホイールが最後にスクロールした時間を確認することです。私は、この目的のために軽量の GCD タイマーを使用することを好みます (strong
ターゲット参照を格納している NSTimer の代わりに、ARC 対応オブジェクトも使用します)。
- (void) scrollWheel:(NSEvent *)event
{
_lastStamp = mach_absolute_time(); // get current timestamp
if (!_running)
{
if (!_timer)
[self createTimerSource];
if (!_running)
dispatch_resume(_timer);
_running = YES;
}
}
- (void)createTimerSource
{
NSTimeInterval timeout = ...;
_timer=dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _timerQueue);
dispatch_source_set_timer(_timer, DISPATCH_TIME_NOW, timeout * NSEC_PER_SEC, 0);
// set the event handler
dispatch_source_set_event_handler(_timer, ^{
uint64_t stamp = mach_absolute_time(); // current stamp
if (stamp - _lastStamp > some_tolerance_value)
{
// wheel did end scroll
if (_running)
dispatch_source_cancel(_timer);
_running = NO;
}
});
}
Dispatch Sourcesの詳細については、記事をご覧ください。