Partager via


UIPasteboard.Notifications.ObserveChanged Méthode

Définition

Surcharges

ObserveChanged(EventHandler<UIPasteboardChangeEventArgs>)

Notification fortement typée pour la ChangedNotification constante.

ObserveChanged(NSObject, EventHandler<UIPasteboardChangeEventArgs>)

Notification fortement typée pour la ChangedNotification constante.

ObserveChanged(EventHandler<UIPasteboardChangeEventArgs>)

Notification fortement typée pour la ChangedNotification constante.

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

Paramètres

handler
EventHandler<UIPasteboardChangeEventArgs>

Méthode à appeler lors de la publication de la notification.

Retours

Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)

Remarques

L’exemple suivant montre comment les développeurs peuvent utiliser cette méthode dans leur code :

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

S’applique à

ObserveChanged(NSObject, EventHandler<UIPasteboardChangeEventArgs>)

Notification fortement typée pour 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

Paramètres

objectToObserve
NSObject

Objet à observer.

handler
EventHandler<UIPasteboardChangeEventArgs>

Méthode à appeler lors de la publication de la notification.

Retours

Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)

Remarques

Cette méthode peut être utilisée pour ChangedNotification s’abonner aux notifications.

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

S’applique à