Bagikan melalui


UIKeyboard.WillShowNotification Properti

Definisi

Konstanta pemberitahuan untuk WillShow

[Foundation.Advice("Use UIKeyboard.Notifications.ObserveWillShow helper method instead.")]
[Foundation.Field("UIKeyboardWillShowNotification", "UIKit")]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)]
public static Foundation.NSString WillShowNotification { [ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)] get; }
member this.WillShowNotification : Foundation.NSString

Nilai Properti

Konstanta NSString, harus digunakan sebagai token untuk NSNotificationCenter.

Atribut

Keterangan

Konstanta ini dapat digunakan dengan NSNotificationCenter untuk mendaftarkan pendengar untuk pemberitahuan ini. Ini adalah NSString alih-alih string, karena nilai-nilai ini dapat digunakan sebagai token di beberapa pustaka asli alih-alih digunakan murni untuk konten string mereka yang sebenarnya. Parameter 'pemberitahuan' ke panggilan balik berisi informasi tambahan yang khusus untuk jenis pemberitahuan.

Jika Anda ingin berlangganan pemberitahuan ini, Anda dapat menggunakan metode .ObserveWillShow yang UIKeyboard.Notificationsmenawarkan akses yang sangat ditik ke parameter pemberitahuan.

Contoh berikut menunjukkan cara menggunakan kelas Pemberitahuan yang ditik dengan kuat, untuk mengeluarkan tebakan dari properti yang tersedia dalam pemberitahuan:

//
// Lambda style
//

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

    Console.WriteLine ("FrameBegin", args.FrameBegin);
    Console.WriteLine ("FrameEnd", args.FrameEnd);
    Console.WriteLine ("AnimationDuration", args.AnimationDuration);
    Console.WriteLine ("AnimationCurve", args.AnimationCurve);
});

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

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

    Console.WriteLine ("FrameBegin", args.FrameBegin);
    Console.WriteLine ("FrameEnd", args.FrameEnd);
    Console.WriteLine ("AnimationDuration", args.AnimationDuration);
    Console.WriteLine ("AnimationCurve", args.AnimationCurve);
}

void Setup ()
{
    notification = UIKeyboard.Notifications.ObserveWillShow (Callback);
}

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

Contoh berikut menunjukkan cara menggunakan pemberitahuan dengan DEFAULTCenter API:

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


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

void Setup ()
{
    NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillShowNotification, Callback);
}

Berlaku untuk