Freigeben über


AVCaptureSession.RuntimeErrorNotification Eigenschaft

Definition

Benachrichtigungskonstante für RuntimeError

[Foundation.Advice("Use AVCaptureSession.Notifications.ObserveRuntimeError helper method instead.")]
[Foundation.Field("AVCaptureSessionRuntimeErrorNotification", "AVFoundation")]
public static Foundation.NSString RuntimeErrorNotification { get; }
member this.RuntimeErrorNotification : Foundation.NSString

Eigenschaftswert

Die NSString-Konstante sollte als Token für NSNotificationCenter verwendet werden.

Attribute

Hinweise

Diese Konstante kann mit dem NSNotificationCenter verwendet werden, um einen Listener für diese Benachrichtigung zu registrieren. Dies ist ein NSString anstelle einer Zeichenfolge, da diese Werte als Token in einigen nativen Bibliotheken verwendet werden können, anstatt nur für ihren tatsächlichen Zeichenfolgeninhalt verwendet zu werden. Der Parameter "notification" für den Rückruf enthält zusätzliche Informationen, die für den Benachrichtigungstyp spezifisch sind.

Um diese Benachrichtigung zu abonnieren, können Entwickler die praktische AVCaptureSession.NotificationsMethode verwenden,ObserveRuntimeError die stark typisierten Zugriff auf die Parameter der Benachrichtigung bietet.

Das folgende Beispiel zeigt, wie Sie die stark typisierte Benachrichtigungsklasse verwenden, um das Rätselraten aus den verfügbaren Eigenschaften in der Benachrichtigung zu nehmen:

//
// Lambda style
//

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

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

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

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

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

void Setup ()
{
    notification = AVCaptureSession.Notifications.ObserveRuntimeError (Callback);
}

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

Das folgende Beispiel zeigt, wie Sie die Benachrichtigung mit der DefaultCenter-API verwenden:

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


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

void Setup ()
{
    NSNotificationCenter.DefaultCenter.AddObserver (AVCaptureSession.RuntimeErrorNotification, Callback);
}

Gilt für: