What is a peek and pop force on new iPhones?

250 views Asked by At

iOS 9.0 added new property force on UITouch class. For new iPhones (6S) this enables to get value of user's finger presure.

The value of force property seems to be set between 0 and 6.66667.

Also iOS 9 added peek and pop feature - when a user aplies certain finger presure level on some controls, programed action is triggered.

My question is: What are these presure levels (for peek and pop) in terms of value of the force property of UITouch?

In another words, to what value do I need to set threshold for the force property for the user to be required to apply the same finger pressure level as when they use 'peek' (or pop) feature?

2

There are 2 answers

0
Mahesh K On

You can try to observe the force value by using the below function. It seems that for a peek the force value is 1.33 (normalized force = 0.20) and for a pop the force value is 5.0 (normalized force = 0.75.) At the peek force level, it triggers the UIViewControllerPreviewingDelegate method (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location for peek.

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)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
    }
}
1
Vishnu gondlekar On

By default you don't need to set force threshold for pop and peek operations, values are predefined in the framework. You can refer this link https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/3DTouchAPIs.html on how to implement peek and pop in your view controller. If you want to customise when to peek and pop then you should be checking force value which is not recommended. As per apple documentation

The force of the touch, where a value of 1.0 represents the force of an average touch (predetermined by the system, not user-specific).

Peek is basically for showing preview for which you will have to implemented various things. You can get sample code here https://developer.apple.com/library/ios/samplecode/ViewControllerPreviews/Introduction/Intro.html. Pop is normal action.