OGeek|极客世界-中国程序员成长平台

标题: ios - 什么是新 iPhone 上的偷看和流行力量? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 14:02
标题: ios - 什么是新 iPhone 上的偷看和流行力量?

iOS 9.0 在 UITouch 类上添加了新属性 force。对于新 iPhone (6S),这可以获取用户手指压力的值。

force 属性的值似乎设置在 0 到 6.66667 之间。

iOS 9 还添加了 peek and pop 功能 - 当用户在某些控件上应用特定的手指压力级别时,会触发程序操作。

我的问题是:就 UITouchforce 属性的值而言,这些压力级别(用于 peek 和 pop)是多少?

换句话说,我需要将 force 属性的阈值设置为什么值,以要求用户应用与使用“peek”(或弹出)时相同的手指压力水平) 功能?



Best Answer-推荐答案


您可以尝试使用以下函数来观察 force 的值。看来,对于 peek,force 值是 1.33(标准化力 = 0.20),对于 pop,force 值是 5.0(标准化力 = 0.75)。 force 级别,它触发 UIViewControllerPreviewingDelegate 方法 (UIViewController *)previewingContextid)previewingContext viewControllerForLocationCGPoint)location 进行 peek .

- (void)touchesMovedNSSet<UITouch *> *)touches withEventUIEvent *)event
{
    [super touchesMoved:touches withEvent:event];

    UITouch *touch = [touches anyObject];

    CGFloat maximumPossibleForce = touch.maximumPossibleForce;
    CGFloat force = touch.force;

    NSLog(@"***** force value : %f", force);

    CGFloat normalizedForce = force/maximumPossibleForce;

    NSLog(@"Normalized force : %f", normalizedForce);

    if (normalizedForce > 0.75)
    {
        // Pop
    }
    else if (normalizedForce > 0.20)
    {
        // Peek
    }
}

关于ios - 什么是新 iPhone 上的偷看和流行力量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35097830/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4