Compartilhar via


UIApplication.Notifications.ObserveWillChangeStatusBarOrientation Método

Definição

Sobrecargas

ObserveWillChangeStatusBarOrientation(EventHandler<UIStatusBarOrientationChangeEventArgs>)

Notificação fortemente tipada para a WillChangeStatusBarOrientationNotification constante.

ObserveWillChangeStatusBarOrientation(NSObject, EventHandler<UIStatusBarOrientationChangeEventArgs>)

Notificação fortemente tipada para a WillChangeStatusBarOrientationNotification constante.

ObserveWillChangeStatusBarOrientation(EventHandler<UIStatusBarOrientationChangeEventArgs>)

Notificação fortemente tipada para a WillChangeStatusBarOrientationNotification constante.

public static Foundation.NSObject ObserveWillChangeStatusBarOrientation (EventHandler<UIKit.UIStatusBarOrientationChangeEventArgs> handler);
static member ObserveWillChangeStatusBarOrientation : EventHandler<UIKit.UIStatusBarOrientationChangeEventArgs> -> Foundation.NSObject

Parâmetros

handler
EventHandler<UIStatusBarOrientationChangeEventArgs>

Método a ser invocado quando a notificação é postada.

Retornos

Objeto de token que pode ser usado para parar de receber notificações descartando-o ou passando-o para RemoveObservers(IEnumerable<NSObject>)

Comentários

O exemplo a seguir mostra como os desenvolvedores podem usar esse método em seu código:

//
// 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 ();
}

Aplica-se a

ObserveWillChangeStatusBarOrientation(NSObject, EventHandler<UIStatusBarOrientationChangeEventArgs>)

Notificação fortemente tipada para a WillChangeStatusBarOrientationNotification constante.

public static Foundation.NSObject ObserveWillChangeStatusBarOrientation (Foundation.NSObject objectToObserve, EventHandler<UIKit.UIStatusBarOrientationChangeEventArgs> handler);
static member ObserveWillChangeStatusBarOrientation : Foundation.NSObject * EventHandler<UIKit.UIStatusBarOrientationChangeEventArgs> -> Foundation.NSObject

Parâmetros

objectToObserve
NSObject

O objeto a ser observado.

handler
EventHandler<UIStatusBarOrientationChangeEventArgs>

Método a ser invocado quando a notificação é postada.

Retornos

Objeto de token que pode ser usado para parar de receber notificações descartando-o ou passando-o para RemoveObservers(IEnumerable<NSObject>)

Comentários

Esse método pode ser usado para assinar WillChangeStatusBarOrientationNotification notificações.

// Listen to all notifications posted for any object
var token = UIApplication.Notifications.ObserveWillChangeStatusBarOrientation ((notification) => {
	Console.WriteLine ("Observed WillChangeStatusBarOrientationNotification!");
};

// Listen to all notifications posted for a single object
var token = UIApplication.Notifications.ObserveWillChangeStatusBarOrientation (objectToObserve, (notification) => {
	Console.WriteLine ($"Observed WillChangeStatusBarOrientationNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

Aplica-se a