Compartir a través de


UIPasteboard.Notifications.ObserveChanged Método

Definición

Sobrecargas

ObserveChanged(EventHandler<UIPasteboardChangeEventArgs>)

Notificación fuertemente tipada para la ChangedNotification constante.

ObserveChanged(NSObject, EventHandler<UIPasteboardChangeEventArgs>)

Notificación fuertemente tipada para la ChangedNotification constante.

ObserveChanged(EventHandler<UIPasteboardChangeEventArgs>)

Notificación fuertemente tipada para la ChangedNotification constante.

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

Parámetros

handler
EventHandler<UIPasteboardChangeEventArgs>

Método que se invoca cuando se publica la notificación.

Devoluciones

Objeto token que se puede usar para dejar de recibir notificaciones mediante su eliminación o su paso 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 = UIPasteboard.Notifications.ObserveChanged ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("TypesAdded", args.TypesAdded);
    Console.WriteLine ("TypesRemoved", args.TypesRemoved);
});

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

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

    Console.WriteLine ("TypesAdded", args.TypesAdded);
    Console.WriteLine ("TypesRemoved", args.TypesRemoved);
}

void Setup ()
{
    notification = UIPasteboard.Notifications.ObserveChanged (Callback);
}

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

Se aplica a

ObserveChanged(NSObject, EventHandler<UIPasteboardChangeEventArgs>)

Notificación fuertemente tipada para la ChangedNotification constante.

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

Parámetros

objectToObserve
NSObject

Objeto que se va a observar.

handler
EventHandler<UIPasteboardChangeEventArgs>

Método que se invoca cuando se publica la notificación.

Devoluciones

Objeto token que se puede usar para dejar de recibir notificaciones mediante su eliminación o su paso a RemoveObservers(IEnumerable<NSObject>)

Comentarios

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

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

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

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

Se aplica a