MonoTouch NSNotificationCenter.DefaultCenter.AddObserver 现在已经过时了吗?

发布于 2024-10-09 02:24:40 字数 216 浏览 0 评论 0原文

我只是想知道: 现代的等价物

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

是什么。它说它已过时,我应该使用 AddObserver,但我不确定 IntPtr 上下文变量使用什么。

I'm just wondering what the modern equivalent of:

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

would be. It says its obsolete and that I should use AddObserver, but I'm not sure what to use for the IntPtr context var.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独自←快乐 2024-10-16 02:24:40

你不需要 IntPtr 变体,如果你读过 Obsolete 方法,它说:

“使用 AddObserver(NSString, Action) 代替”

所以你想要的是

NotificationCenter.DefaultCenter.AddObserver (UIDevice.OrientationDidChangeNotification, receivedRotate);

You don't need the IntPtr variant, if you read the Obsolete method it says:

"Use AddObserver(NSString, Action) instead"

So what you want is

NotificationCenter.DefaultCenter.AddObserver (UIDevice.OrientationDidChangeNotification, receivedRotate);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文