Share via


UIApplication.Notifications.ObserveContentSizeCategoryChanged Método

Definición

Sobrecargas

ObserveContentSizeCategoryChanged(EventHandler<UIContentSizeCategoryChangedEventArgs>)

Notificación fuertemente tipada para la ContentSizeCategoryChangedNotification constante.

ObserveContentSizeCategoryChanged(NSObject, EventHandler<UIContentSizeCategoryChangedEventArgs>)

Notificación fuertemente tipada para la ContentSizeCategoryChangedNotification constante.

ObserveContentSizeCategoryChanged(EventHandler<UIContentSizeCategoryChangedEventArgs>)

Notificación fuertemente tipada para la ContentSizeCategoryChangedNotification constante.

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

Parámetros

handler
EventHandler<UIContentSizeCategoryChangedEventArgs>

Método para invocar cuando se publica la notificación.

Devoluciones

Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)

Comentarios

En el ejemplo siguiente se muestra cómo los desarrolladores pueden usar este método en su código:

//
// Lambda style
//

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

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

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

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

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

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

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

Se aplica a

ObserveContentSizeCategoryChanged(NSObject, EventHandler<UIContentSizeCategoryChangedEventArgs>)

Notificación fuertemente tipada para la ContentSizeCategoryChangedNotification constante.

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

Parámetros

objectToObserve
NSObject

Objeto que se va a observar.

handler
EventHandler<UIContentSizeCategoryChangedEventArgs>

Método para invocar cuando se publica la notificación.

Devoluciones

Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)

Comentarios

Este método se puede usar para suscribirse ContentSizeCategoryChangedNotification a las notificaciones.

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

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

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

Se aplica a