如何直接从其事件ObserveOrientationDidChange中获取强类型的方向?

问题描述

编辑:建议的副本确实提供了一种获取方向的方法。谢谢你。但它没有展示如何以 Microsoft 文档中提到的方式获取强类型通知

ObserveOrientationDidChange 的文档说:

OrientationDidChangeNotification 的

强类型通知 持续的。 [强调我的]

但是这个例子只是无用的:

// Access strongly typed args
Console.WriteLine ("Notification: {0}",args.Notification);

所以在设置之后:

var notification = UIDevice.Notifications.ObserveOrientationDidChange(OrientationChanged);

我尝试将其转换为 UIDeviceOrientation

void OrientationChanged(object sender,NSNotificationEventArgs e)
{            
    UIDeviceOrientation o = (UIDeviceOrientation)e.Notification;
}

但我收到一个错误

错误 CS0030 无法将类型“Foundation.NSNotification”转换为 'UIKit.UIDeviceOrientation'

那么我如何从这个事件中获得强类型(如微软上述文档中所述)?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)