c# - 在跨平台 xamarin 项目中编写特定于平台的代码
问题描述
我尝试在我的跨平台 Xamarin 项目中使用 Xamarin.Android 命名空间。当我现在构建 .iOS 项目时,我收到通知,这个命名空间显然不存在于 iOS 中。
我如何编写特定于平台的代码,在哪里使用特定于平台的库?
我已经检查了 Microsoft Docs,但没有找到任何可以解决我的问题的信息。
PS:这是我对 Stack Overflow 的第一个贡献,请随时询问更多详细信息。
解决方案
欢迎来到堆栈溢出。
以上是 DependencyService 文档的链接。DependencyService 允许您作为开发人员从您的 Xamarin.Forms 共享代码中调用特定于平台的代码。
推荐阅读
- c# - 如何在服务而不是后台进程下运行 c# windows service 应用程序?
- javascript - 请问如何创建 JQuery 播放列表?
- flutter - 如何在颤振中获取构建之外的上下文?
- reactjs - 如何使用另一个 docker 容器作为主网站的子目录?
- xamarin - 如何使用 EAAccessoryManager Xamarin Forms 将 ESP32 连接到 iPhone?
- python - 从分类器输出中提取字典值
- regex - 根据条件打印字符串之间的行
- django - 我收到完整性错误,在 django 中将数据发送到 POST api 时
- azure - 使用事件中心命名空间上定义的策略将事件发布到 Azure 事件中心
- azure - 使用 Microsoft Graph API 在 azure AD 中注册(创建)应用程序的方法