What is the sampling rate for touchMove Cocoa Touch?

When the touch moves, touchMove is called by the system. What is the interval between two moves?

+3
source share
2 answers

There is no fixed rate. Information is interrupted due to hardware and is processed by the OS. If you are writing an application that simply records touchsMoved events, you can feel it - it is very fast.

, angular, , . , : , .

, , :

( -. , .)

static NSDate *touchReportDate = nil;
static touchMovedCount = 0;

- (void) logTouches
{
    NSDate *saveDate = touchReportDate;
    int saveCount = touchMovedCount;
    touchReportDate = nil;
    touchMovedCount = 0;
    NSTimeInterval secs = -[saveDate timeIntervalSinceNow];
    [saveDate release];

    NSLog (@"%d touches in %0.2f seconds (%0.2f t/s)", saveCount, secs, (saveCount / secs));
}


- (void) touchesMoved: (NSSet *touches withEvent: (UIEvent*) event
{
    if (touchReportDate == nil)
        touchReportDate = [[NSDate date] retain];

    if ([touchReportDate timeIntervalSinceNow] < -1)  // report every second
    {
        [self logTouches]
    }
}


- (void) touchesEnded: (NSSet *touches) withEvent: (UIEvent*) event
{
    [self logTouches];
}

- (void) touchesCancelled: (NSSet *touches) withEvent: (UIEvent*) event
{
    [self touchesEnded: touches withEvent: event];
}
+2

, WWDC 2015 Session 233: Advanced Touch Input iOS, 60 , ( 2015) iPad Air 2, 120 . iPad Air 2 2015 , , , 120 .

, 60 . iPad Air 2, -[UIEvent coalescedTouchesForTouch:].

60 ( 120) , , 1/60 .

+3

Source: https://habr.com/ru/post/1739678/


All Articles