Поделиться через


AVCaptureSession.WasInterruptedNotification Свойство

Определение

Константы уведомлений для WasInterrupted

[Foundation.Advice("Use AVCaptureSession.Notifications.ObserveWasInterrupted helper method instead.")]
[Foundation.Field("AVCaptureSessionWasInterruptedNotification", "AVFoundation")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.MacOSX, 10, 14, ObjCRuntime.PlatformArchitecture.Arch64, null)]
public static Foundation.NSString WasInterruptedNotification { [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.MacOSX, 10, 14, ObjCRuntime.PlatformArchitecture.Arch64, null)] get; }
member this.WasInterruptedNotification : Foundation.NSString

Значение свойства

Константа NSString должна использоваться в качестве маркера для NSNotificationCenter.

Атрибуты

Комментарии

Эту константу можно использовать с для NSNotificationCenter регистрации прослушивателя для этого уведомления. Это NSString вместо строки, так как эти значения могут использоваться в качестве маркеров в некоторых собственных библиотеках, а не только для их фактического содержимого строки. Параметр notification для обратного вызова содержит дополнительные сведения, относящиеся к типу уведомления.

Если вы хотите подписаться на это уведомление, можно использовать удобный AVCaptureSession.Notificationsметод .ObserveWasInterrupted , который предоставляет строго типизированный доступ к параметрам уведомления.

В следующем примере показано, как использовать строго типизированный класс Notifications, чтобы вывести догадки из доступных свойств в уведомлении:

//
// Lambda style
//

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

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

В следующем примере показано, как использовать уведомление с API DefaultCenter:

// Lambda style
NSNotificationCenter.DefaultCenter.AddObserver (
        AVCaptureSession.WasInterruptedNotification, (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.WasInterruptedNotification, Callback);
}

Применяется к