AVCaptureDevice.Notifications.ObserveWasDisconnected Método

Definición

Sobrecargas

ObserveWasDisconnected(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la WasDisconnectedNotification constante.

ObserveWasDisconnected(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la WasDisconnectedNotification constante.

ObserveWasDisconnected(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la WasDisconnectedNotification constante.

public static Foundation.NSObject ObserveWasDisconnected (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveWasDisconnected : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parámetros

handler
EventHandler<NSNotificationEventArgs>

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 puede usar este método en el código.

//
// Lambda style
//

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

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

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

void Setup ()
{
    notification = AVCaptureDevice.Notifications.ObserveWasDisconnected (Callback);
}

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

Se aplica a

ObserveWasDisconnected(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la WasDisconnectedNotification constante.

public static Foundation.NSObject ObserveWasDisconnected (Foundation.NSObject objectToObserve, EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveWasDisconnected : Foundation.NSObject * EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parámetros

objectToObserve
NSObject

Objeto específico que se va a observar.

handler
EventHandler<NSNotificationEventArgs>

Controlador que responde a la notificación cuando se produce.

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 WasDisconnectedNotification a las notificaciones.

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

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

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

Se aplica a