UIApplication.Notifications.ObserveWillChangeStatusBarFrame 方法

定义

重载

ObserveWillChangeStatusBarFrame(EventHandler<UIStatusBarFrameChangeEventArgs>)

常量的强类型通知 WillChangeStatusBarFrameNotification

ObserveWillChangeStatusBarFrame(NSObject, EventHandler<UIStatusBarFrameChangeEventArgs>)

常量的强类型通知 WillChangeStatusBarFrameNotification

ObserveWillChangeStatusBarFrame(EventHandler<UIStatusBarFrameChangeEventArgs>)

常量的强类型通知 WillChangeStatusBarFrameNotification

public static Foundation.NSObject ObserveWillChangeStatusBarFrame (EventHandler<UIKit.UIStatusBarFrameChangeEventArgs> handler);
static member ObserveWillChangeStatusBarFrame : EventHandler<UIKit.UIStatusBarFrameChangeEventArgs> -> Foundation.NSObject

参数

handler
EventHandler<UIStatusBarFrameChangeEventArgs>

发布通知时调用的方法。

返回

令牌对象,可用于通过释放通知或将其传递给来停止接收通知 RemoveObservers(IEnumerable<NSObject>)

注解

以下示例演示开发人员如何在代码中使用此方法:

//
// Lambda style
//

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

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

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

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

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

void Setup ()
{
    notification = UIApplication.Notifications.ObserveWillChangeStatusBarFrame (Callback);
}

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

适用于

ObserveWillChangeStatusBarFrame(NSObject, EventHandler<UIStatusBarFrameChangeEventArgs>)

常量的强类型通知 WillChangeStatusBarFrameNotification

public static Foundation.NSObject ObserveWillChangeStatusBarFrame (Foundation.NSObject objectToObserve, EventHandler<UIKit.UIStatusBarFrameChangeEventArgs> handler);
static member ObserveWillChangeStatusBarFrame : Foundation.NSObject * EventHandler<UIKit.UIStatusBarFrameChangeEventArgs> -> Foundation.NSObject

参数

objectToObserve
NSObject

要观察的对象。

handler
EventHandler<UIStatusBarFrameChangeEventArgs>

发布通知时调用的方法。

返回

令牌对象,可用于通过释放通知或将其传递给来停止接收通知 RemoveObservers(IEnumerable<NSObject>)

注解

此方法可用于订阅 WillChangeStatusBarFrameNotification 通知。

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

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

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

适用于