3

我只是想知道现代相当于什么:

NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", receivedRotate);

将会。它说它已经过时了,我应该使用 AddObserver,但我不确定要为 IntPtr 上下文变量使用什么。

4

1 回答 1

7

您不需要 IntPtr 变体,如果您阅读 Obsolete 方法,它会说:

“改用 AddObserver(NSString, Action)”

所以你想要的是

NotificationCenter.DefaultCenter.AddObserver (UIDevice.OrientationDidChangeNotification, receivedRotate);
于 2010-12-27T03:18:46.183 回答