c# - 如何直接从其事件(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”
那么如何从该事件中获取强类型值(如 Microsoft 上述文档中所述)?
解决方案
推荐阅读
- c++ - 如何为字体文件创建 IDOMFont 实例?
- spring-data - @Query (Spring data/JPA) 在 where 条件下带有布尔值
- angular - Angular 6 到 7 升级导致使用延迟加载概念缺少启动模块的错误
- rxjs - 确定 Observable 是否“可完成”
- firebase - 超过下载限制后何时禁用firebase数据库?
- c# - 无法访问同一命名空间中的其他公共类
- grapevine - 如何在 Grapevine 中创建动态路径
- wordpress - 手动将 opencart 更改为 woocommerce
- c# - 带有 Rhino 模拟的 NUnit 测试方法不起作用 - C#
- mysql - Mysql选择多列并按单列分组