Share via


AVCaptureDevice.WasConnectedNotification Proprietà

Definizione

Costante di notifica per WasConnected

[Foundation.Advice("Use AVCaptureDevice.Notifications.ObserveWasConnected helper method instead.")]
[Foundation.Field("AVCaptureDeviceWasConnectedNotification", "AVFoundation")]
public static Foundation.NSString WasConnectedNotification { get; }
member this.WasConnectedNotification : Foundation.NSString

Valore della proprietà

La costante NSString deve essere usata come token per NSNotificationCenter.

Attributi

Commenti

Questa costante può essere usata con per NSNotificationCenter registrare un listener per questa notifica. Si tratta di un NSString anziché di una stringa, perché questi valori possono essere usati come token in alcune librerie native anziché essere usati esclusivamente per il contenuto stringa effettivo. Il parametro 'notification' del callback contiene informazioni aggiuntive specifiche per il tipo di notifica.

Se si vuole sottoscrivere questa notifica, è possibile usare il AVCaptureDevice.NotificationsObserveWasConnected metodo . praticità che offre l'accesso fortemente tipizzato ai parametri della notifica.

Nell'esempio seguente viene illustrato come usare la classe Notifiche fortemente tipizzata, per eseguire i tentativi di indovinare le proprietà disponibili nella notifica:

//
// Lambda style
//

// listening
notification = AVCaptureDevice.Notifications.ObserveWasConnected ((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.ObserveWasConnected (Callback);
}

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

Nell'esempio seguente viene illustrato come usare la notifica con l'API DefaultCenter:

// Lambda style
NSNotificationCenter.DefaultCenter.AddObserver (
        AVCaptureDevice.WasConnectedNotification, (notification) => {Console.WriteLine ("Received the notification AVCaptureDevice", notification); }


// Method style
void Callback (NSNotification notification)
{
    Console.WriteLine ("Received a notification AVCaptureDevice", notification);
}

void Setup ()
{
    NSNotificationCenter.DefaultCenter.AddObserver (AVCaptureDevice.WasConnectedNotification, Callback);
}

Si applica a