Freigeben über


UIApplication.WillChangeStatusBarOrientationNotification Eigenschaft

Definition

Benachrichtigungskonstante für WillChangeStatusBarOrientation

[Foundation.Advice("Use UIApplication.Notifications.ObserveWillChangeStatusBarOrientation helper method instead.")]
[Foundation.Field("UIApplicationWillChangeStatusBarOrientationNotification", "UIKit")]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)]
public static Foundation.NSString WillChangeStatusBarOrientationNotification { [ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)] get; }
member this.WillChangeStatusBarOrientationNotification : Foundation.NSString

Eigenschaftswert

Die NSString-Konstante sollte als Token für NSNotificationCenter verwendet werden.

Attribute

Hinweise

Diese Konstante kann mit dem NSNotificationCenter verwendet werden, um einen Listener für diese Benachrichtigung zu registrieren. Dies ist ein NSString anstelle einer Zeichenfolge, da diese Werte als Token in einigen nativen Bibliotheken verwendet werden können, anstatt nur für ihren tatsächlichen Zeichenfolgeninhalt verwendet zu werden. Der Parameter "notification" für den Rückruf enthält zusätzliche Informationen, die für den Benachrichtigungstyp spezifisch sind.

Um diese Benachrichtigung zu abonnieren, können Entwickler die praktische UIApplication.NotificationsMethode verwenden,ObserveWillChangeStatusBarOrientation die stark typisierten Zugriff auf die Parameter der Benachrichtigung bietet.

Das folgende Beispiel zeigt, wie Sie die stark typisierte Benachrichtigungsklasse verwenden, um das Rätselraten aus den verfügbaren Eigenschaften in der Benachrichtigung zu nehmen:

//
// Lambda style
//

// listening
notification = UIApplication.Notifications.ObserveWillChangeStatusBarOrientation ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("StatusBarOrientation", args.StatusBarOrientation);
});

// To stop listening:
notification.Dispose ();

//
// Method style
//
NSObject notification;
void Callback (object sender, UIKit.UIStatusBarOrientationChangeEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("StatusBarOrientation", args.StatusBarOrientation);
}

void Setup ()
{
    notification = UIApplication.Notifications.ObserveWillChangeStatusBarOrientation (Callback);
}

void Teardown ()
{
    notification.Dispose ();
}

Das folgende Beispiel zeigt, wie Sie die Benachrichtigung mit der DefaultCenter-API verwenden:

// Lambda style
NSNotificationCenter.DefaultCenter.AddObserver (
        UIApplication.WillChangeStatusBarOrientationNotification, (notification) => {Console.WriteLine ("Received the notification UIApplication", notification); }


// Method style
void Callback (NSNotification notification)
{
    Console.WriteLine ("Received a notification UIApplication", notification);
}

void Setup ()
{
    NSNotificationCenter.DefaultCenter.AddObserver (UIApplication.WillChangeStatusBarOrientationNotification, Callback);
}

Gilt für: