Compartir a través de


UITextView.Notifications.ObserveTextDidChange Método

Definición

Sobrecargas

ObserveTextDidChange(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la TextDidChangeNotification constante.

ObserveTextDidChange(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la TextDidChangeNotification constante.

ObserveTextDidChange(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la TextDidChangeNotification constante.

public static Foundation.NSObject ObserveTextDidChange (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveTextDidChange : 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 = UITextView.Notifications.ObserveTextDidChange ((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 = UITextView.Notifications.ObserveTextDidChange (Callback);
}

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

Se aplica a

ObserveTextDidChange(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la TextDidChangeNotification constante.

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

Parámetros

objectToObserve
NSObject

Objeto que se va a observar.

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

Este método se puede usar para suscribirse TextDidChangeNotification a las notificaciones.

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

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

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

Se aplica a