UIViewController.RegisterForPreviewingWithDelegate Method

Definition

Registers this view controller for 3D Touch peek and pop operations.

[Foundation.Export("registerForPreviewingWithDelegate:sourceView:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual UIKit.IUIViewControllerPreviewing RegisterForPreviewingWithDelegate (UIKit.IUIViewControllerPreviewingDelegate previewingDelegate, UIKit.UIView sourceView);
abstract member RegisterForPreviewingWithDelegate : UIKit.IUIViewControllerPreviewingDelegate * UIKit.UIView -> UIKit.IUIViewControllerPreviewing
override this.RegisterForPreviewingWithDelegate : UIKit.IUIViewControllerPreviewingDelegate * UIKit.UIView -> UIKit.IUIViewControllerPreviewing

Parameters

previewingDelegate
IUIViewControllerPreviewingDelegate

The delegate that controls the display of peeks and pops in response to variations in user-applied pressure.

sourceView
UIView

The view, in the receiver's view hierarchy, that supplies the peek, or preview, view.

Returns

The context for the preview.

Attributes

Remarks

App developers call this method to register this view controller as the one that displays preview and commit force gestures, specify the source view that will remain visually focused prior to peeking, and specify the delegate that responds to forceful touch from the user. App developers can rely on automatic life cycle management for the context that is returned, or manually release it by calling the UnregisterForPreviewingWithContext(IUIViewControllerPreviewing) method.

Application developers who want to preserve the option to unregister for 3D Touch peek and pop must store a reference to the IUIViewControllerPreviewing instance that is returned by RegisterForPreviewingWithDelegate(IUIViewControllerPreviewingDelegate, UIView), so that they can later pass it to the UnregisterForPreviewingWithContext(IUIViewControllerPreviewing) method.

This method should typically be called in an override of TraitCollectionDidChange(UITraitCollection) in the initial UIViewController of the app.

public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection)
{
    base.TraitCollectionDidChange(previousTraitCollection);

    if (TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available) {
        // Register for 3D Touch Peek and Pop
        RegisterForPreviewingWithDelegate(new PreviewingDelegate(), View);
    }
}

Applies to