UIViewController.TraitCollectionDidChange(UITraitCollection) Method

Definition

Method invoked when the trait collection for the view controller changed.

[Foundation.Export("traitCollectionDidChange:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 8, 0, ObjCRuntime.PlatformArchitecture.All, null)]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 8, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual void TraitCollectionDidChange (UIKit.UITraitCollection previousTraitCollection);
abstract member TraitCollectionDidChange : UIKit.UITraitCollection -> unit
override this.TraitCollectionDidChange : UIKit.UITraitCollection -> unit

Parameters

previousTraitCollection
UITraitCollection

The previous set of traits. When this method is invoked, the TraitCollection property has already been updated to reflect the new active traits.

Implements

Attributes

Remarks

Application developers can override this method to adjust the user interface to react to changes to the user interface traits, such as the horizontal and vertical size classes for the application.

Application developers must call the base implementation at the beginning of their override.

This method is the appropriate place to register for 3D Touch with RegisterForPreviewingWithDelegate(IUIViewControllerPreviewingDelegate, UIView):

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

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

Applies to